mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-23 18:54:05 +01:00
log: import 'conf' in a way that works with REHASH
This commit is contained in:
parent
126a07bdf6
commit
3b93a521d6
9
log.py
9
log.py
@ -11,13 +11,12 @@ import logging.handlers
|
||||
import sys
|
||||
import os
|
||||
|
||||
from . import world
|
||||
from .conf import conf, confname
|
||||
from . import world, conf
|
||||
|
||||
# Stores a list of active file loggers.
|
||||
fileloggers = []
|
||||
|
||||
stdout_level = conf['logging'].get('stdout') or 'INFO'
|
||||
stdout_level = conf.conf['logging'].get('stdout') or 'INFO'
|
||||
|
||||
logdir = os.path.join(os.getcwd(), 'log')
|
||||
os.makedirs(logdir, exist_ok=True)
|
||||
@ -45,7 +44,7 @@ def makeFileLogger(filename, level=None):
|
||||
"""
|
||||
# Use log names specific to the current instance, to prevent multiple
|
||||
# PyLink instances from overwriting each others' log files.
|
||||
target = os.path.join(logdir, '%s-%s.log' % (confname, filename))
|
||||
target = os.path.join(logdir, '%s-%s.log' % (conf.confname, filename))
|
||||
|
||||
# TODO: configurable values here
|
||||
filelogger = logging.handlers.RotatingFileHandler(target, maxBytes=52428800, backupCount=5)
|
||||
@ -72,7 +71,7 @@ def stopFileLoggers():
|
||||
fileloggers.remove(handler)
|
||||
|
||||
# Set up file logging now, creating a file logger for each block.
|
||||
files = conf['logging'].get('files')
|
||||
files = conf.conf['logging'].get('files')
|
||||
if files:
|
||||
for filename, config in files.items():
|
||||
makeFileLogger(filename, config.get('loglevel'))
|
||||
|
Loading…
Reference in New Issue
Block a user