Closed vvviperrr closed 1 year ago
Hi, thanks for the PR!
But first I have to ask a stupid question: Why is this better than piping stdout and stderr to logger(1)?
Hi, thanks for the PR!
But first I have to ask a stupid question: Why is this better than piping stdout and stderr to logger(1)?
Hi. The main reason - support different syslog priorities. Sure, we can achieve this via piping earlyoom's stdout & stderr in different logger instances with different facilities\levels, but this trick is really ugly. something like this (example from busybox sysctl script)
xargs -0 -r -n 1 readlink -f | {
prog_status="OK"
while :; do
read -r file || {
echo "$prog_status" >&4
break
}
echo "* Applying $file ..."
/sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err
} 3>&1 | /usr/bin/logger -t sysctl -p kern.info
the things become more complicated, when u need start earlyoom via start-stop-daemon.
so patching earlyoom code is just handy (by adding syslog param in default conf file) & portable solution.
Ok, understood. I will accept syslog support.
I merged this, thanks. Two more things if you have time:
1) Can you add --syslog
to https://github.com/rfjakob/earlyoom/blob/master/MANPAGE.md
2) The startup messages still go to stdout, seems to be they should be going to syslog as well:
$ ./earlyoom --syslog
earlyoom v1.7-36-g848653f
mem total: 23881 MiB, user mem total: 21593 MiB, swap total: 8191 MiB
sending SIGTERM when mem <= 10.00% and swap <= 10.00%,
SIGKILL when mem <= 5.00% and swap <= 5.00%
syslog logging is useful in embedded applications, e.g in buildroot software