add simple log-facility (replace when syslogd available)
This commit is contained in:
parent
f70b2677d1
commit
917dae5a96
17
log_helpers.sh
Executable file
17
log_helpers.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user