From 65034c98c8664e3efdc5074a529f1e1e9df83a5f Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Wed, 11 Sep 2019 23:36:18 +0300 Subject: [PATCH] Improved logging configuration. Allow numeric log levels and NOTICE --- dyngo | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dyngo b/dyngo index dcfe779..0b02240 100755 --- a/dyngo +++ b/dyngo @@ -92,8 +92,18 @@ if len(config.read(options["-f"]))!=1: print("Cannot read config %s"%options["-f"],file=sys.stderr) sys.exit(1) conf=config['dyngo'] +if conf['loglevel'].isdigit(): + level=int(conf['loglevel']) +else: + try: + logging.NOTICE=25 + level=getattr(logging,conf['loglevel'].upper()) + except AttributeError: + print("Invalid logleevel '%s'"%conf('loglevel')) + sys.exit(1) + logging.basicConfig(format="%(asctime)s %(message)s", - level=getattr(logging,conf['loglevel'].upper())) + level=level, stream=sys.stderr) interval=int(conf['interval']) database=dbm.open(conf['database'],"c") https_params={} -- 2.39.2