From 7496d5505e2af3aab3dda60e6d39c3f284043bd5 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Mon, 26 Oct 2020 11:36:52 +0000 Subject: [PATCH] Resolve #16: Verbosity config should be levels not binary Resolves: #16 --- README.md | 2 +- alertify.py | 11 ++++++++--- src/alertify/config.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 13ba164..1e8a3fe 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The following environment variables will override any config or default: * GOTIFY_PORT (default: 80) * GOTIFY_SERVER (default: localhost) * LISTEN_PORT (default: 8080) - * VERBOSE (default: False) + * VERBOSE (default: 0) ``` diff --git a/alertify.py b/alertify.py index 1579446..906477a 100644 --- a/alertify.py +++ b/alertify.py @@ -59,9 +59,14 @@ if __name__ == '__main__': # forwarder = alertify.Alertify(args.config) forwarder = alertify.Alertify() - if forwarder.config.verbose: - logger = logging.getLogger() - logger.setLevel(logging.DEBUG) + #----------------------------- + # Calculate logging level + #----------------------------- + # Config :: Verbose: 0 = WARNING, 1 = INFO, 2 = DEBUG + # Logging :: Loglevel: 30 = WARNING, 20 = INFO, 10 = DEBUG + logger = logging.getLogger() + logger.setLevel(30 - (forwarder.config.verbose * 10)) + #----------------------------- if args.healthcheck: # Invert the sense of 'healthy' for Unix CLI usage diff --git a/src/alertify/config.py b/src/alertify/config.py index 948eab6..155e5f7 100644 --- a/src/alertify/config.py +++ b/src/alertify/config.py @@ -21,7 +21,7 @@ class Config: gotify_port = int(80) gotify_server = str('localhost') listen_port = int(8080) - verbose = bool(False) + verbose = int(0) def __init__(self, configfile=None): """