add simple log-facility (replace when syslogd available)

This commit is contained in:
Gerhard Hoffmann 2022-06-04 14:00:53 +02:00
parent f70b2677d1
commit 917dae5a96

17
log_helpers.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# set -x
log() {
local log_file=/var/log/update_controller.log
if [ -f "$log_file" ]; then
touch $log_file
fi
if [ $(wc -l < $log_file) > 100000 ]; then
# remove first line
sed -e 1d -i $log_file
fi
message="$(date +'%D_%T'): $*"
printf "$message\n"
printf "$message\n" >> $log_file
}
# log "test message1" "test message2"