From a069ce8cb402d36c5012bf3c7f3f39b45ad2d3d1 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 23 Apr 2016 11:05:49 -0700 Subject: [PATCH] Unbrick loglevel changing (Closes #208) --- log.py | 9 +++++---- plugins/commands.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) 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)