Elucidating comment, as well as filtering of misc.log when plugins are using their individual logfiles.

This commit is contained in:
Jeremy Fincher 2004-09-29 18:51:37 +00:00
parent 3a6779bb6d
commit 04e5ff9b7a
1 changed files with 12 additions and 2 deletions

View File

@ -202,6 +202,8 @@ class ValidLogLevel(registry.String):
self.setValue(level) self.setValue(level)
def __str__(self): def __str__(self):
# The str() is necessary here; apparently getLevelName returns an
# integer on occasion. logging--
level = str(logging.getLevelName(self.value)) level = str(logging.getLevelName(self.value))
if level.startswith('Level'): if level.startswith('Level'):
level = level.split()[-1] level = level.split()[-1]
@ -229,7 +231,7 @@ conf.registerGlobalValue(conf.supybot.log, 'level',
will be. Valid values are VERBOSE, DEBUG, INFO, WARNING, ERROR, will be. Valid values are VERBOSE, DEBUG, INFO, WARNING, ERROR,
and CRITICAL, in order of increasing priority.""")) and CRITICAL, in order of increasing priority."""))
conf.registerGlobalValue(conf.supybot.log, 'statistics', conf.registerGlobalValue(conf.supybot.log, 'statistics',
ValidLogLevel('VERBOSE', """Determines what level statistics reporting ValidLogLevel(-1, """Determines what level statistics reporting
is to be logged at. Mostly, this just includes, for instance, the time it is to be logged at. Mostly, this just includes, for instance, the time it
took to parse a message, process a command, etc. You probably don't care took to parse a message, process a command, etc. You probably don't care
about this.""")) about this."""))
@ -382,12 +384,20 @@ if not os.path.exists(pluginLogDir):
_handler = BetterFileHandler(os.path.join(_logDir, 'misc.log')) _handler = BetterFileHandler(os.path.join(_logDir, 'misc.log'))
_handler.setFormatter(formatter) _handler.setFormatter(formatter)
_handler.setLevel(-1) _handler.setLevel(-1)
class PluginLogFilter(logging.Filter):
def filter(self, record):
if conf.supybot.log.plugins.individualLogfiles():
if record.msg.name.startswith('supybot.plugins'):
return False
return True
_handler.addFilter(PluginLogFilter())
_logger.addHandler(_handler) _logger.addHandler(_handler)
_logger.setLevel(conf.supybot.log.level()) _logger.setLevel(conf.supybot.log.level())
if not conf.daemonized: if not conf.daemonized:
_stdoutHandler = StdoutStreamHandler(sys.stdout) _stdoutHandler = StdoutStreamHandler(sys.stdout)
_stdoutFormatter = ColorizedFormatter('YOU SHOULD NEVER SEE THIS!') _stdoutFormatter = ColorizedFormatter('IF YOU SEE THIS, FILE A BUG!')
_stdoutHandler.setFormatter(_stdoutFormatter) _stdoutHandler.setFormatter(_stdoutFormatter)
_stdoutHandler.setLevel(-1) _stdoutHandler.setLevel(-1)
_logger.addHandler(_stdoutHandler) _logger.addHandler(_stdoutHandler)