3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +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 logging
import sys import sys
import os import os
import world
from conf import conf, confname from conf import conf, confname
@ -24,13 +25,13 @@ _format = '%(asctime)s [%(levelname)s] %(message)s'
logformatter = logging.Formatter(_format) logformatter = logging.Formatter(_format)
# Set up logging to STDERR # Set up logging to STDERR
stdout_handler = logging.StreamHandler() world.stdout_handler = logging.StreamHandler()
stdout_handler.setFormatter(logformatter) world.stdout_handler.setFormatter(logformatter)
stdout_handler.setLevel(stdout_level) world.stdout_handler.setLevel(stdout_level)
# Get the main logger object; plugins can import this variable for convenience. # Get the main logger object; plugins can import this variable for convenience.
log = logging.getLogger() 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 # 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 # 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) irc.reply('Error: Unknown log level "%s".' % level)
return return
else: else:
log.setLevel(loglevel) world.stdout_handler.setLevel(loglevel)
irc.reply("Done.") irc.reply("Done.")
except IndexError: except IndexError:
irc.reply(log.getEffectiveLevel()) irc.reply(world.stdout_handler.level)