diff --git a/CHANGELOG.md b/CHANGELOG.md index 11d554bac6e63d12e63212db42a99d39707bcbf6..ed911e4138c1f2aaf0cde0740056343d249b087d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ changed functionality, fixed bugs). ## Version 2.0.8 (in development) - Fixed parsing of `--config` CLI param on Python 3.5 +- Added `--debug` CLI parameter to easily enable debug logging without having + to edit `flamenco-worker.cfg`. ## Version 2.0.7 (released 2017-07-04) diff --git a/flamenco_worker/cli.py b/flamenco_worker/cli.py index 5ab4e4871e0a2bbbed4192c8e16335189013df29..b44673fce31185481188c75ed82028d2198df27f 100644 --- a/flamenco_worker/cli.py +++ b/flamenco_worker/cli.py @@ -20,12 +20,16 @@ def main(): help="Erases authentication information and re-registers this worker " "at the Manager. WARNING: this can cause duplicate worker information " "in the Manager's database.") + parser.add_argument('-d', '--debug', action='store_true', + help="Enables debug logging for Flamenco Worker's own log entries. " + "Edit the logging config in flamenco-worker.cfg " + "for more powerful options.") args = parser.parse_args() # Load configuration from . import config confparser = config.load_config(args.config, args.verbose) - config.configure_logging(confparser) + config.configure_logging(confparser, enable_debug=args.debug) log = logging.getLogger(__name__) log.debug('Starting') diff --git a/flamenco_worker/config.py b/flamenco_worker/config.py index c85c2c034e5d49497624acf5d614aaaf58548bb5..bb809f560d3f449a58b29726af8d8ced7418fa80 100644 --- a/flamenco_worker/config.py +++ b/flamenco_worker/config.py @@ -116,8 +116,12 @@ def load_config(config_file: pathlib.Path = None, return confparser -def configure_logging(confparser: configparser.ConfigParser): +def configure_logging(confparser: configparser.ConfigParser, enable_debug: bool): import logging.config logging.config.fileConfig(confparser, disable_existing_loggers=True) logging.captureWarnings(capture=True) + + if enable_debug: + logging.getLogger('flamenco_worker').setLevel(logging.DEBUG) + log.debug('Enabling debug logging')