From 17972b87aaa409cc9194318fc44fd059173dd2dc Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 3 Jan 2019 19:28:45 -0800 Subject: [PATCH] Allow setting of log level via WUBLOADER_LOG_LEVEL env var By using an env var, it is universal and happens prior to arg parsing, at the same point we do other logging setup. --- downloader/downloader/__main__.py | 4 +++- restreamer/restreamer/__main__.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/downloader/downloader/__main__.py b/downloader/downloader/__main__.py index 45d813e..2f2fa3f 100644 --- a/downloader/downloader/__main__.py +++ b/downloader/downloader/__main__.py @@ -3,6 +3,7 @@ import gevent.monkey gevent.monkey.patch_all() import logging +import os import argh @@ -10,5 +11,6 @@ from downloader.main import main LOG_FORMAT = "[%(asctime)s] %(levelname)8s %(name)s(%(module)s:%(lineno)d): %(message)s" -logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) +level = os.environ.get('WUBLOADER_LOG_LEVEL', 'INFO').upper() +logging.basicConfig(level=level, format=LOG_FORMAT) argh.dispatch_command(main) diff --git a/restreamer/restreamer/__main__.py b/restreamer/restreamer/__main__.py index 24935eb..f0ad12b 100644 --- a/restreamer/restreamer/__main__.py +++ b/restreamer/restreamer/__main__.py @@ -3,6 +3,7 @@ import gevent.monkey gevent.monkey.patch_all() import logging +import os import argh @@ -10,5 +11,6 @@ from restreamer.main import main LOG_FORMAT = "[%(asctime)s] %(levelname)8s %(name)s(%(module)s:%(lineno)d): %(message)s" -logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) +level = os.environ.get('WUBLOADER_LOG_LEVEL', 'INFO').upper() +logging.basicConfig(level=level, format=LOG_FORMAT) argh.dispatch_command(main)