From 750e878ffd4b0fca77c37b0e8ec1b363d93bad41 Mon Sep 17 00:00:00 2001 From: slice Date: Wed, 26 Jul 2017 17:09:19 -0700 Subject: [PATCH] [config] allow logging level to be configurable (#47) --- .gitignore | 1 + disco/cli.py | 7 ++++--- disco/client.py | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 72302f2..1b1a6ae 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ storage.json *.dca .eggs/ .cache/ +__pycache__ # Documentation stuff docs/api/ diff --git a/disco/cli.py b/disco/cli.py index 918043f..201b068 100644 --- a/disco/cli.py +++ b/disco/cli.py @@ -24,7 +24,7 @@ parser.add_argument('--manhole-bind', help='host:port for the manhole to bind to parser.add_argument('--encoder', help='encoder for gateway data', default=None) parser.add_argument('--run-bot', help='run a disco bot on this client', action='store_true', default=False) parser.add_argument('--plugin', help='load plugins into the bot', nargs='*', default=[]) -parser.add_argument('--log-level', help='log level', default='info') +parser.add_argument('--log-level', help='log level', default=None) parser.add_argument('--http-bind', help='bind information for http server', default=None) @@ -53,6 +53,8 @@ def disco_main(run=False): config.manhole_enable = args.manhole if args.manhole_bind: config.manhole_bind = args.manhole_bind + if args.log_level: + config.log_level = args.log_level for k, v in six.iteritems(vars(args)): if hasattr(config, k) and v is not None: @@ -67,8 +69,7 @@ def disco_main(run=False): AutoSharder(config).run() return - # TODO: make configurable - setup_logging(level=getattr(logging, args.log_level.upper())) + setup_logging(level=getattr(logging, config.log_level.upper())) client = Client(config) diff --git a/disco/client.py b/disco/client.py index 478f226..a407ab2 100644 --- a/disco/client.py +++ b/disco/client.py @@ -28,6 +28,8 @@ class ClientConfig(Config): The total count of shards running. max_reconnects : int The maximum number of connection retries to make before giving up (0 = never give up). + log_level: str + The logging level to use. manhole_enable : bool Whether to enable the manhole (e.g. console backdoor server) utility. manhole_bind : tuple(str, int) @@ -42,6 +44,7 @@ class ClientConfig(Config): shard_id = 0 shard_count = 1 max_reconnects = 5 + log_level = 'info' manhole_enable = False manhole_bind = ('127.0.0.1', 8484)