mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Apply "log" environment variables to config
This commit is contained in:
parent
788f2f7277
commit
dc00e16fda
@ -34,7 +34,9 @@ def configure_bigchaindb(command):
|
|||||||
"""
|
"""
|
||||||
@functools.wraps(command)
|
@functools.wraps(command)
|
||||||
def configure(args):
|
def configure(args):
|
||||||
|
config_from_cmdline = None
|
||||||
try:
|
try:
|
||||||
|
if args.log_level is not None:
|
||||||
config_from_cmdline = {
|
config_from_cmdline = {
|
||||||
'log': {
|
'log': {
|
||||||
'level_console': args.log_level,
|
'level_console': args.log_level,
|
||||||
@ -43,7 +45,7 @@ def configure_bigchaindb(command):
|
|||||||
'server': {'loglevel': args.log_level},
|
'server': {'loglevel': args.log_level},
|
||||||
}
|
}
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
config_from_cmdline = None
|
pass
|
||||||
bigchaindb.config_utils.autoconfigure(
|
bigchaindb.config_utils.autoconfigure(
|
||||||
filename=args.config, config=config_from_cmdline, force=True)
|
filename=args.config, config=config_from_cmdline, force=True)
|
||||||
command(args)
|
command(args)
|
||||||
@ -238,10 +240,11 @@ base_parser.add_argument('-c', '--config',
|
|||||||
help='Specify the location of the configuration file '
|
help='Specify the location of the configuration file '
|
||||||
'(use "-" for stdout)')
|
'(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',
|
base_parser.add_argument('-l', '--log-level',
|
||||||
type=str.upper, # convert to uppercase for comparison to choices
|
type=str.upper, # convert to uppercase for comparison to choices
|
||||||
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
|
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
|
||||||
default='INFO',
|
|
||||||
help='Log level')
|
help='Log level')
|
||||||
|
|
||||||
base_parser.add_argument('-y', '--yes', '--yes-please',
|
base_parser.add_argument('-y', '--yes', '--yes-please',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user