From 16519ee35ad069248abfe901f89c4b46d6ae2d23 Mon Sep 17 00:00:00 2001 From: Dan Srebnick Date: Thu, 28 Sep 2017 11:19:57 -0400 Subject: [PATCH] Add logging command line switch --- README | 5 ++++- noaacap/usr/local/bin/noaacap.py | 21 +++++++++++++-------- noaacap/usr/local/share/noaacap/CHANGELOG | 1 + noaacap/usr/local/share/noaacap/README | 5 ++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README b/README index f66661f..1658d79 100644 --- a/README +++ b/README @@ -36,6 +36,9 @@ aprx.log, then you likely need to add the timeout. The program will check for a new alert or update every 2 minutes, but only send if there is a change. +For visibility into noaacap's actions via the systemd journal, you may add +--info or --debug to the exec command line for more verbose logging. + Edit /etc/noaacap.conf: Do not remove the [noaacap] section header. @@ -60,4 +63,4 @@ k2dls@k2dls.net with the callsign-SSID of your APRS station that is sending weather alerts via this program. Dan Srebnick, K2DLS -09/13/2017 +09/28/2017 diff --git a/noaacap/usr/local/bin/noaacap.py b/noaacap/usr/local/bin/noaacap.py index f0150ff..37d614c 100755 --- a/noaacap/usr/local/bin/noaacap.py +++ b/noaacap/usr/local/bin/noaacap.py @@ -24,15 +24,20 @@ from systemd.journal import JournalHandler log = logging.getLogger('noaacap') log.addHandler(JournalHandler(SYSLOG_IDENTIFIER='noaacap')) -log.setLevel(logging.INFO) -log.info("Starting") -if len(sys.argv) == 2 and sys.argv[1] == '-v': - print("noaacap.py by K2DLS, version " + version + "\n") - print("A weather alert beacon exec for aprx >= 2.9") - print("Licensed under the BSD 2 Clause license") - print("Copyright 2017 by Daniel L. Srebnick\n") - sys.exit(0) +if len(sys.argv) == 2: + if sys.argv[1] == '-v': + print("noaacap.py by K2DLS, version " + version + "\n") + print("A weather alert beacon exec for aprx >= 2.9") + print("Licensed under the BSD 2 Clause license") + print("Copyright 2017 by Daniel L. Srebnick\n") + sys.exit(0) + elif sys.argv[1] == "--info": + log.setLevel(logging.INFO) + elif sys.argv[1] == "--debug": + log.setLevel(logging.DEBUG) + +log.info("Starting") # We need this function early in execution def Exiting(): diff --git a/noaacap/usr/local/share/noaacap/CHANGELOG b/noaacap/usr/local/share/noaacap/CHANGELOG index d96563b..5dd72da 100644 --- a/noaacap/usr/local/share/noaacap/CHANGELOG +++ b/noaacap/usr/local/share/noaacap/CHANGELOG @@ -3,6 +3,7 @@ noaacap changelog Version: 0.7 Release: TBD Added myResend parameter to control message resends. +Added command line parameters --info and --debug to control logging ## Version: 0.6 Release: September 15, 2017 diff --git a/noaacap/usr/local/share/noaacap/README b/noaacap/usr/local/share/noaacap/README index e6e0afd..5b13eb5 100644 --- a/noaacap/usr/local/share/noaacap/README +++ b/noaacap/usr/local/share/noaacap/README @@ -31,6 +31,9 @@ aprx.log, then you likely need to add the timeout. The program will check for a new alert or update every 2 minutes, but only send if there is a change. +For visibility into noaacap's actions via the systemd journal, you may add +--info or --debug to the exec command line for more verbose logging. + Edit /etc/noaacap.conf: Do not remove the [noaacap] section header. @@ -55,4 +58,4 @@ k2dls@k2dls.net with the callsign-SSID of your APRS station that is sending weather alerts via this program. Dan Srebnick, K2DLS -09/13/2017 +09/28/2017