From: Victor Wagner Date: Wed, 11 Sep 2019 20:36:18 +0000 (+0300) Subject: Improved logging configuration. Allow numeric log levels and NOTICE X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=65034c98c8664e3efdc5074a529f1e1e9df83a5f;p=oss%2Fdyngo.git Improved logging configuration. Allow numeric log levels and NOTICE --- 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={}