Move logger-setup to tsstats.logger
and handlers are now attached as desired in __main__.cli
This commit is contained in:
parent
2753f548fe
commit
0033ce186f
|
@ -1,15 +1 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
logger = logging.getLogger('tsstats')
|
|
||||||
logger.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
fh = logging.FileHandler('debug.txt', 'w', delay=True)
|
|
||||||
fh.setLevel(logging.DEBUG)
|
|
||||||
|
|
||||||
ch = logging.StreamHandler()
|
|
||||||
ch.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
logger.addHandler(fh)
|
|
||||||
logger.addHandler(ch)
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from os.path import abspath, exists
|
||||||
from tsstats import config
|
from tsstats import config
|
||||||
from tsstats.exceptions import InvalidConfiguration
|
from tsstats.exceptions import InvalidConfiguration
|
||||||
from tsstats.log import parse_logs
|
from tsstats.log import parse_logs
|
||||||
|
from tsstats.logger import file_handler, stream_handler
|
||||||
from tsstats.template import render_servers
|
from tsstats.template import render_servers
|
||||||
from tsstats.utils import transform_pretty_identmap
|
from tsstats.utils import transform_pretty_identmap
|
||||||
|
|
||||||
|
@ -67,8 +68,12 @@ def cli():
|
||||||
|
|
||||||
|
|
||||||
def main(configuration):
|
def main(configuration):
|
||||||
|
# setup logging
|
||||||
if configuration.getboolean('General', 'debug'):
|
if configuration.getboolean('General', 'debug'):
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
# attach handlers
|
||||||
|
logger.addHandler(file_handler)
|
||||||
|
logger.addHandler(stream_handler)
|
||||||
|
|
||||||
idmap = configuration.get('General', 'idmap')
|
idmap = configuration.get('General', 'idmap')
|
||||||
if idmap:
|
if idmap:
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# setup logger
|
||||||
|
logger = logging.getLogger('tsstats')
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
# define handlers
|
||||||
|
file_handler = logging.FileHandler('debug.txt', 'w', delay=True)
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
stream_handler = logging.StreamHandler()
|
||||||
|
stream_handler.setLevel(logging.INFO)
|
Loading…
Reference in New Issue