From 8f49c3e95dcc1bc8a11afe4beed9654b80fa127c Mon Sep 17 00:00:00 2001 From: Thor77 Date: Mon, 27 Feb 2017 12:39:31 +0100 Subject: [PATCH] Add debugstdout flag/config-directive to enable debug logging to stdout Fix #15 --- tsstats/__main__.py | 9 ++++++++- tsstats/config.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tsstats/__main__.py b/tsstats/__main__.py index b31d475..b364e0c 100644 --- a/tsstats/__main__.py +++ b/tsstats/__main__.py @@ -40,6 +40,10 @@ def cli(): '-d', '--debug', help='debug mode', action='store_true' ) + parser.add_argument( + '-ds', '--debugstdout', + help='write debug output to stdout', action='store_true' + ) parser.add_argument( '-nod', '--noonlinedc', help='don\'t add connect until now to onlinetime', @@ -71,9 +75,12 @@ def main(configuration): # setup logging if configuration.getboolean('General', 'debug'): logger.setLevel(logging.DEBUG) + if configuration.getboolean('General', 'debugstdout'): + stream_handler.setLevel(logging.DEBUG) + # attach handlers - logger.addHandler(file_handler) logger.addHandler(stream_handler) + logger.addHandler(file_handler) idmap = configuration.get('General', 'idmap') if idmap: diff --git a/tsstats/config.py b/tsstats/config.py index fcee7e0..8ed3a87 100644 --- a/tsstats/config.py +++ b/tsstats/config.py @@ -13,6 +13,7 @@ logger = logging.getLogger('tsstats') DEFAULT_CONFIG = { 'General': { 'debug': False, + 'debugstdout': False, 'log': '', 'output': 'tsstats.html', 'idmap': '',