Made stdout stuff dynamically check the value of supybot.log.stdout.

This commit is contained in:
Jeremy Fincher 2004-02-02 00:59:02 +00:00
parent 651db477ae
commit 92b2bd31cf

View File

@ -81,6 +81,11 @@ class BetterStreamHandler(logging.StreamHandler):
self.stream.write("%s\n" % msg.encode("UTF-8")) self.stream.write("%s\n" % msg.encode("UTF-8"))
self.flush() self.flush()
class StdoutStreamHandler(BetterStreamHandler):
def emit(self, record):
if conf.supybot.log.stdout():
BetterStreamHandler.emit(self, record)
class BetterFileHandler(logging.FileHandler): class BetterFileHandler(logging.FileHandler):
def emit(self, record): def emit(self, record):
@ -231,8 +236,7 @@ _handler.setLevel(-1)
_logger.addHandler(_handler) _logger.addHandler(_handler)
_logger.setLevel(conf.supybot.log.level()) _logger.setLevel(conf.supybot.log.level())
if conf.supybot.log.stdout(): _stdoutHandler = StdoutStreamHandler(sys.stdout)
_stdoutHandler = BetterStreamHandler(sys.stdout)
_formatString = '%(name)s: %(levelname)s %(message)s' _formatString = '%(name)s: %(levelname)s %(message)s'
_stdoutFormatter = ColorizedFormatter(_formatString) _stdoutFormatter = ColorizedFormatter(_formatString)
_stdoutHandler.setFormatter(_stdoutFormatter) _stdoutHandler.setFormatter(_stdoutFormatter)