alternatives to runit log process
I dislike the standard runit logging for some reasons.
1) it doesn't seem to separate stdout/stderr
2) the outputs are hidden in sub-folders of /var/log which can hinder searches
3) it splits off the logging process into another run/finish etc etc
I tried a few experiments to allow direct logging in the original run script. Here is an example which splits stdout / stderr into
different destinations. The comment at line 2 shows how logger could be used to provide standard kernel type logging.
Logger doesn't seem to allow a specific filename to be used.
To do that the code line 3 to the redirect exec shows how a bash script can be used to filter stdout/stderr to different files in /var/log.
The trap and sed use is based on https://unix.stackexchange.com/questions/440426/how-to-prefix-any-output-in-a-bash-script
#!/bin/bash
#exec > >(logger -t'TLOG #####') 2> >(logger -t'TLOG !!!!!')
filt(){
while read line; do
d="$(TZ=UTC date +'%Y-%m-%d %H:%M:%S')"
echo "$line" | sed -e's/^/'"$d"' /'
done
}
exec > >(trap "" INT TERM EXIT; filt >> /var/log/tlog.log) \
2> >(trap "" INT TERM EXIT; filt >> /var/log/tlog-error.log)
echo "############### TLOG start"
echo "############### TLOG start" 1>&2
for i in 1 2 3 4 5; do
sleep 20
echo "this is message $i to stdout"
echo "this is message $i to stderr" 1>&2
done
pause