]> wagner.pp.ru Git - oss/dyngo.git/commitdiff
Improved logging configuration. Allow numeric log levels and NOTICE
authorVictor Wagner <vitus@wagner.pp.ru>
Wed, 11 Sep 2019 20:36:18 +0000 (23:36 +0300)
committerVictor Wagner <vitus@wagner.pp.ru>
Wed, 11 Sep 2019 20:36:18 +0000 (23:36 +0300)
dyngo

diff --git a/dyngo b/dyngo
index dcfe779ebe2da6c3bd7d80a4dd32e0b8e890cf6e..0b02240be9fdda1af23ba51195f9ddf1ac525402 100755 (executable)
--- 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={}