mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added logging of version of plugin in plugin logs.
This commit is contained in:
parent
9dc2618232
commit
532db9c456
15
src/log.py
15
src/log.py
@ -89,7 +89,7 @@ class BetterFileHandler(logging.FileHandler):
|
||||
except UnicodeError:
|
||||
self.stream.write("%s\n" % msg.encode("UTF-8"))
|
||||
self.flush()
|
||||
|
||||
|
||||
|
||||
class DailyRotatingHandler(BetterFileHandler):
|
||||
def __init__(self, *args):
|
||||
@ -159,6 +159,19 @@ def getPluginLogger(name):
|
||||
handler.setLevel(-1)
|
||||
handler.setFormatter(pluginFormatter)
|
||||
log.addHandler(handler)
|
||||
if name in sys.modules:
|
||||
# Let's log the version, this might be useful.
|
||||
module = sys.modules[name]
|
||||
try:
|
||||
if hasattr(module, '__revision__'):
|
||||
version = module.__revision__.split()[2]
|
||||
log.info('Starting log for %s (revision %s)', name, version)
|
||||
else:
|
||||
debug('Module %s has no __revision__ string.', name)
|
||||
log.info('Starting log for %s.', name)
|
||||
except IndexError:
|
||||
log.debug('Improper __revision__ string in %s.', name)
|
||||
log.info('Starting log for %s.', name)
|
||||
return log
|
||||
|
||||
def timestamp(when=None):
|
||||
|
Loading…
Reference in New Issue
Block a user