mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-22 02:32:42 +01:00
Added exception revision logging.
This commit is contained in:
parent
2faa09670a
commit
74763d4dec
11
src/fix.py
11
src/fix.py
@ -42,6 +42,7 @@ __all__ = []
|
||||
exported = ['ignore', 'reversed', 'window', 'group',
|
||||
'partition', 'any', 'all', 'rsplit']
|
||||
|
||||
import sys
|
||||
import new
|
||||
import string
|
||||
string.ascii = string.maketrans('', '')
|
||||
@ -196,6 +197,16 @@ import socket
|
||||
# Some socket modules don't have sslerror, so we'll just make it an error.
|
||||
if not hasattr(socket, 'sslerror'):
|
||||
socket.sslerror = socket.error
|
||||
|
||||
# Trick to get an __revision__ attribute in all exceptions, if possible.
|
||||
Exception__init__ = Exception.__init__
|
||||
def __init__(self, *args, **kwargs):
|
||||
caller = sys._getframe(1)
|
||||
module = sys.modules.get(caller.f_globals.get('__name__'))
|
||||
self.__revision__ = getattr(module, '__revision__', None)
|
||||
Exception__init__(self, *args, **kwargs)
|
||||
Exception.__init__ = __init__
|
||||
|
||||
|
||||
for name in exported:
|
||||
__builtins__[name] = globals()[name]
|
||||
|
@ -77,6 +77,8 @@ class Logger(logging.Logger):
|
||||
eStrId = '%s:%s' % (E, path)
|
||||
eId = hex(hash(eStrId) & 0xFFFFF)
|
||||
logging.Logger.exception(self, *args)
|
||||
if hasattr(e, '__revision__') and e.__revision__:
|
||||
self.error('Exception __revision__: %r', e.__revision__)
|
||||
self.error('Exception id: %s', eId)
|
||||
# The traceback should be sufficient if we want it.
|
||||
# self.error('Exception string: %s', eStrId)
|
||||
|
Loading…
Reference in New Issue
Block a user