From dc00e16fda2c3960611c29af48b18121d1ad90bc Mon Sep 17 00:00:00 2001 From: kansi Date: Mon, 23 Oct 2017 16:00:09 +0530 Subject: [PATCH] Apply "log" environment variables to config --- bigchaindb/commands/utils.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bigchaindb/commands/utils.py b/bigchaindb/commands/utils.py index d6840d68..11d97395 100644 --- a/bigchaindb/commands/utils.py +++ b/bigchaindb/commands/utils.py @@ -34,16 +34,18 @@ def configure_bigchaindb(command): """ @functools.wraps(command) def configure(args): + config_from_cmdline = None try: - config_from_cmdline = { - 'log': { - 'level_console': args.log_level, - 'level_logfile': args.log_level, - }, - 'server': {'loglevel': args.log_level}, - } + if args.log_level is not None: + config_from_cmdline = { + 'log': { + 'level_console': args.log_level, + 'level_logfile': args.log_level, + }, + 'server': {'loglevel': args.log_level}, + } except AttributeError: - config_from_cmdline = None + pass bigchaindb.config_utils.autoconfigure( filename=args.config, config=config_from_cmdline, force=True) command(args) @@ -238,10 +240,11 @@ base_parser.add_argument('-c', '--config', help='Specify the location of the configuration file ' '(use "-" for stdout)') +# NOTE: this flag should not have any default value because that will override +# the environment variables provided to configure the logger. base_parser.add_argument('-l', '--log-level', type=str.upper, # convert to uppercase for comparison to choices choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], - default='INFO', help='Log level') base_parser.add_argument('-y', '--yes', '--yes-please',