mirror of https://github.com/Mikaela/Limnoria.git
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',
|
exported = ['ignore', 'reversed', 'window', 'group',
|
||||||
'partition', 'any', 'all', 'rsplit']
|
'partition', 'any', 'all', 'rsplit']
|
||||||
|
|
||||||
|
import sys
|
||||||
import new
|
import new
|
||||||
import string
|
import string
|
||||||
string.ascii = string.maketrans('', '')
|
string.ascii = string.maketrans('', '')
|
||||||
|
@ -197,6 +198,16 @@ import socket
|
||||||
if not hasattr(socket, 'sslerror'):
|
if not hasattr(socket, 'sslerror'):
|
||||||
socket.sslerror = socket.error
|
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:
|
for name in exported:
|
||||||
__builtins__[name] = globals()[name]
|
__builtins__[name] = globals()[name]
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ class Logger(logging.Logger):
|
||||||
eStrId = '%s:%s' % (E, path)
|
eStrId = '%s:%s' % (E, path)
|
||||||
eId = hex(hash(eStrId) & 0xFFFFF)
|
eId = hex(hash(eStrId) & 0xFFFFF)
|
||||||
logging.Logger.exception(self, *args)
|
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)
|
self.error('Exception id: %s', eId)
|
||||||
# The traceback should be sufficient if we want it.
|
# The traceback should be sufficient if we want it.
|
||||||
# self.error('Exception string: %s', eStrId)
|
# self.error('Exception string: %s', eStrId)
|
||||||
|
|
Loading…
Reference in New Issue