3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 19:52:53 +01:00

Unbrick loglevel changing (Closes #208)

This commit is contained in:
James Lu 2016-04-23 11:05:49 -07:00
parent 128a6363d5
commit a069ce8cb4
2 changed files with 7 additions and 6 deletions

9
log.py
View File

@ -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

View File

@ -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)