Added logging of version of plugin in plugin logs.

This commit is contained in:
Jeremy Fincher 2004-03-25 12:17:48 +00:00
parent 9dc2618232
commit 532db9c456

View File

@ -89,7 +89,7 @@ class BetterFileHandler(logging.FileHandler):
except UnicodeError: except UnicodeError:
self.stream.write("%s\n" % msg.encode("UTF-8")) self.stream.write("%s\n" % msg.encode("UTF-8"))
self.flush() self.flush()
class DailyRotatingHandler(BetterFileHandler): class DailyRotatingHandler(BetterFileHandler):
def __init__(self, *args): def __init__(self, *args):
@ -159,6 +159,19 @@ def getPluginLogger(name):
handler.setLevel(-1) handler.setLevel(-1)
handler.setFormatter(pluginFormatter) handler.setFormatter(pluginFormatter)
log.addHandler(handler) 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 return log
def timestamp(when=None): def timestamp(when=None):