nodewatcher: Output to stderr instead of log file

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@blaese.de>
Reviewed-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Fabian Bläse 2020-04-22 16:05:24 +02:00
parent 6c947f8c91
commit c1f694c319
2 changed files with 2 additions and 26 deletions

View File

@ -2,8 +2,6 @@ touch /etc/config/nodewatcher
uci batch <<EOF
add nodewatcher script
set nodewatcher.@script[-1].error_level='0'
set nodewatcher.@script[-1].logfile='/var/log/nodewatcher.log'
set nodewatcher.@script[-1].data_file='/tmp/crawldata/node.data'
set nodewatcher.@script[-1].status_text_file='/tmp/status.txt'
EOF

View File

@ -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 "$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 "$(date): Logfile has been made smaller"
fi
fi
debug() {
(>&2 echo "$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 "$(date): Check logfile"
delete_log
#Erzeugt die statusdaten
debug "$(date): Generate actual status data"
crawl