Fix0red the problems with VERBOSE.

This commit is contained in:
Jeremy Fincher 2004-09-29 04:07:29 +00:00
parent e01a9d3bc5
commit a382087fc4

View File

@ -56,7 +56,8 @@ deadlyExceptions = [KeyboardInterrupt, SystemExit]
### ###
testing = False testing = False
logging.addLevelName(1, 'VERBOSE') VERBOSE = 1
logging.addLevelName(VERBOSE, 'VERBOSE')
class Formatter(logging.Formatter): class Formatter(logging.Formatter):
_fmtConf = staticmethod(lambda : conf.supybot.log.format()) _fmtConf = staticmethod(lambda : conf.supybot.log.format())
@ -93,7 +94,7 @@ class Logger(logging.Logger):
# self.error('Exception string: %s', eStrId) # self.error('Exception string: %s', eStrId)
def verbose(self, *args, **kwargs): def verbose(self, *args, **kwargs):
self.log('VERBOSE', *args, **kwargs) self.log(VERBOSE, *args, **kwargs)
class StdoutStreamHandler(logging.StreamHandler): class StdoutStreamHandler(logging.StreamHandler):
@ -111,6 +112,10 @@ class StdoutStreamHandler(logging.StreamHandler):
if record.levelname != 'ERROR' and conf.supybot.log.stdout.wrap(): if record.levelname != 'ERROR' and conf.supybot.log.stdout.wrap():
# We check for ERROR there because otherwise, tracebacks (which are # We check for ERROR there because otherwise, tracebacks (which are
# already wrapped by Python itself) wrap oddly. # already wrapped by Python itself) wrap oddly.
if not isinstance(record.levelname, basestring):
print record
print record.levelname
print utils.stackTrace()
prefixLen = len(record.levelname) + 1 # ' ' prefixLen = len(record.levelname) + 1 # ' '
s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen) s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen)
s.rstrip('\r\n') s.rstrip('\r\n')
@ -203,8 +208,8 @@ class ValidLogLevel(registry.String):
return level return level
class LogLevel(ValidLogLevel): class LogLevel(ValidLogLevel):
"""Invalid log level. Value must be either DEBUG, INFO, WARNING, ERROR, """Invalid log level. Value must be either VERBOSE, DEBUG, INFO, WARNING,
or CRITICAL.""" ERROR, or CRITICAL."""
def setValue(self, v): def setValue(self, v):
ValidLogLevel.setValue(self, v) ValidLogLevel.setValue(self, v)
_logger.setLevel(self.value) # _logger defined later. _logger.setLevel(self.value) # _logger defined later.
@ -221,8 +226,8 @@ conf.registerGlobalValue(conf.supybot.log, 'format',
its logging module.""")) its logging module."""))
conf.registerGlobalValue(conf.supybot.log, 'level', conf.registerGlobalValue(conf.supybot.log, 'level',
LogLevel(logging.INFO, """Determines what the minimum priority level logged LogLevel(logging.INFO, """Determines what the minimum priority level logged
will be. Valid values are DEBUG, INFO, WARNING, ERROR, and CRITICAL, in will be. Valid values are VERBOSE, DEBUG, INFO, WARNING, ERROR,
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('VERBOSE', """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