From patchwork Sun Apr 19 13:40:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [2/4] nodewatcher: Output to stderr instead of log file From: Fabian Blaese X-Patchwork-Id: 1348 Message-Id: <20200419134020.1389582-2-fabian@blaese.de> To: franken-dev@freifunk.net Date: Sun, 19 Apr 2020 15:40:18 +0200 Maintaining a logfile manually is complicated and has no major improvements over just logging to stderr, because nodewatcher is no deamon and can be run manually for debugging purposes. Also, the debug output from subscripts currently is not written to the log file anyway and the debug level is not used eiher. Therefore, the file logging and debug level is removed from nodewatcher, which simplifies the code a bit. Signed-off-by: Fabian Bläse Reviewed-by: Adrian Schmutzler --- .../files/usr/sbin/nodewatcher | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher index 8da7877..1226f49 100755 --- a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher +++ b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher @@ -14,28 +14,10 @@ trap "lock -u \"$lockfile\"" INT TERM EXIT [ -s /etc/config/nodewatcher ] || exit 1 -SCRIPT_ERROR_LEVEL=$(uci get nodewatcher.@script[0].error_level) -SCRIPT_LOGFILE=$(uci get nodewatcher.@script[0].logfile) SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file) -if [ "$SCRIPT_ERROR_LEVEL" -gt "1" ]; then - debug() { - echo "$(date): $1" >> "$SCRIPT_LOGFILE" - } -else - debug() { - : - } -fi - -#This method checks if the log file has become too big and deletes the first X lines -delete_log() { - if [ -f "$SCRIPT_LOGFILE" ]; then - if [ "$(find "$SCRIPT_LOGFILE" -printf "%s")" -gt "6000" ]; then - sed -i '1,60d' "$SCRIPT_LOGFILE" - debug "Logfile has been made smaller" - fi - fi +debug() { + (>&2 echo "$(date): $1") } #This method generates the crawl data XML file that is being fetched by netmon @@ -60,10 +42,6 @@ crawl() { LANG=C -#Prüft ob das logfile zu groß geworden ist -debug "Check logfile" -delete_log - #Erzeugt die statusdaten debug "Generate actual status data" crawl