mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-24 03:04: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 sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from . import world
|
from . import world, conf
|
||||||
from .conf import conf, confname
|
|
||||||
|
|
||||||
# Stores a list of active file loggers.
|
# Stores a list of active file loggers.
|
||||||
fileloggers = []
|
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')
|
logdir = os.path.join(os.getcwd(), 'log')
|
||||||
os.makedirs(logdir, exist_ok=True)
|
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
|
# Use log names specific to the current instance, to prevent multiple
|
||||||
# PyLink instances from overwriting each others' log files.
|
# 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
|
# TODO: configurable values here
|
||||||
filelogger = logging.handlers.RotatingFileHandler(target, maxBytes=52428800, backupCount=5)
|
filelogger = logging.handlers.RotatingFileHandler(target, maxBytes=52428800, backupCount=5)
|
||||||
@ -72,7 +71,7 @@ def stopFileLoggers():
|
|||||||
fileloggers.remove(handler)
|
fileloggers.remove(handler)
|
||||||
|
|
||||||
# Set up file logging now, creating a file logger for each block.
|
# 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:
|
if files:
|
||||||
for filename, config in files.items():
|
for filename, config in files.items():
|
||||||
makeFileLogger(filename, config.get('loglevel'))
|
makeFileLogger(filename, config.get('loglevel'))
|
||||||
|
Loading…
Reference in New Issue
Block a user