mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
core: update stdout log level on REHASH
This commit is contained in:
parent
a2e7a35998
commit
b2286157ef
@ -6,7 +6,7 @@ import os
|
||||
import threading
|
||||
|
||||
from pylinkirc import world, utils, conf, classes
|
||||
from pylinkirc.log import log, makeFileLogger, stopFileLoggers
|
||||
from pylinkirc.log import log, makeFileLogger, stopFileLoggers, stdoutLogLevel
|
||||
from . import permissions
|
||||
|
||||
def remove_network(ircobj):
|
||||
@ -70,8 +70,11 @@ def _rehash():
|
||||
for filename, config in files.items():
|
||||
makeFileLogger(filename, config.get('loglevel'))
|
||||
|
||||
log.debug('rehash: updating STDOUT log level')
|
||||
world.stdout_handler.setLevel(stdoutLogLevel())
|
||||
|
||||
# Reset permissions.
|
||||
log.debug('rehash: resetting permissions.')
|
||||
log.debug('rehash: resetting permissions')
|
||||
permissions.resetPermissions()
|
||||
|
||||
for network, ircobj in world.networkobjects.copy().items():
|
||||
|
11
log.py
11
log.py
@ -15,18 +15,23 @@ from . import world, conf
|
||||
# Stores a list of active file loggers.
|
||||
fileloggers = []
|
||||
|
||||
stdout_level = conf.conf['logging'].get('stdout') or 'INFO'
|
||||
|
||||
logdir = os.path.join(os.getcwd(), 'log')
|
||||
os.makedirs(logdir, exist_ok=True)
|
||||
|
||||
# TODO: perhaps make this format configurable?
|
||||
_format = '%(asctime)s [%(levelname)s] %(message)s'
|
||||
logformatter = logging.Formatter(_format)
|
||||
|
||||
def stdoutLogLevel():
|
||||
"""
|
||||
Returns the configured STDOUT log level.
|
||||
"""
|
||||
return conf.conf['logging'].get('stdout') or 'INFO'
|
||||
|
||||
# Set up logging to STDERR
|
||||
world.stdout_handler = logging.StreamHandler()
|
||||
world.stdout_handler.setFormatter(logformatter)
|
||||
world.stdout_handler.setLevel(stdout_level)
|
||||
world.stdout_handler.setLevel(stdoutLogLevel())
|
||||
|
||||
# Get the main logger object; plugins can import this variable for convenience.
|
||||
log = logging.getLogger()
|
||||
|
Loading…
Reference in New Issue
Block a user