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:
parent
128a6363d5
commit
a069ce8cb4
9
log.py
9
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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user