diff --git a/log.py b/log.py index 38f5174..e366ac9 100644 --- a/log.py +++ b/log.py @@ -9,6 +9,7 @@ access the global logger object by importing "log" from this module import logging import sys import os +import world from conf import conf, confname @@ -24,13 +25,13 @@ _format = '%(asctime)s [%(levelname)s] %(message)s' logformatter = logging.Formatter(_format) # Set up logging to STDERR -stdout_handler = logging.StreamHandler() -stdout_handler.setFormatter(logformatter) -stdout_handler.setLevel(stdout_level) +world.stdout_handler = logging.StreamHandler() +world.stdout_handler.setFormatter(logformatter) +world.stdout_handler.setLevel(stdout_level) # Get the main logger object; plugins can import this variable for convenience. log = logging.getLogger() -log.addHandler(stdout_handler) +log.addHandler(world.stdout_handler) # This is confusing, but we have to set the root logger to accept all events. Only this way # can other loggers filter out events on their own, instead of having everything dropped by diff --git a/plugins/commands.py b/plugins/commands.py index 5a7e232..dfcc485 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -187,7 +187,7 @@ def loglevel(irc, source, args): irc.reply('Error: Unknown log level "%s".' % level) return else: - log.setLevel(loglevel) + world.stdout_handler.setLevel(loglevel) irc.reply("Done.") except IndexError: - irc.reply(log.getEffectiveLevel()) + irc.reply(world.stdout_handler.level)