[PATCH 2/4] nodewatcher: Output to stderr instead of log file

Fabian Bläse fabian at blaese.de
So Apr 19 15:40:18 CEST 2020


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 <fabian at blaese.de>
---
 .../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. at script[0].error_level)
-SCRIPT_LOGFILE=$(uci get nodewatcher. at script[0].logfile)
 SCRIPT_DATA_FILE=$(uci get nodewatcher. at 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
-- 
2.26.0



Mehr Informationen über die Mailingliste franken-dev