Merge branch 'master' into bug/1660/logging-server-port-config

This commit is contained in:
kansi 2017-10-24 10:10:18 +05:30
commit 0b44c385a6
2 changed files with 18 additions and 15 deletions

View File

@ -34,16 +34,18 @@ def configure_bigchaindb(command):
""" """
@functools.wraps(command) @functools.wraps(command)
def configure(args): def configure(args):
config_from_cmdline = None
try: try:
config_from_cmdline = { if args.log_level is not None:
'log': { config_from_cmdline = {
'level_console': args.log_level, 'log': {
'level_logfile': args.log_level, 'level_console': args.log_level,
}, 'level_logfile': args.log_level,
'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',

View File

@ -142,9 +142,9 @@ def test_is_genesis_block_returns_true_if_genesis(b):
def test_lazy_execution(): def test_lazy_execution():
from bigchaindb.utils import Lazy from bigchaindb.utils import Lazy
l = Lazy() lz = Lazy()
l.split(',')[1].split(' ').pop(1).strip() lz.split(',')[1].split(' ').pop(1).strip()
result = l.run('Like humans, cats tend to favor one paw over another') result = lz.run('Like humans, cats tend to favor one paw over another')
assert result == 'cats' assert result == 'cats'
class Cat: class Cat:
@ -153,7 +153,7 @@ def test_lazy_execution():
cat = Cat('Shmui') cat = Cat('Shmui')
l = Lazy() lz = Lazy()
l.name.upper() lz.name.upper()
result = l.run(cat) result = lz.run(cat)
assert result == 'SHMUI' assert result == 'SHMUI'