syslogize

a wrapper for sending output to syslog when the program doesn't support
it.  if adds syslogging support to daemonize as well.
This commit is contained in:
f 2022-06-04 16:48:38 -03:00
parent 5d2ad04336
commit e38f6a1fe6

20
syslogize.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
# A wrapper for programs that can't write to syslog. Output and error
# are sent to syslog.
#
# Use LOGGER environment variable to pass options to `logger`. They'll
# probably be system-dependent, so handle with care.
#
# Usage:
#
# LOGGER="-t program" syslogize program -o -p --tions argu ments
#
# daemonize syslogize program
if test $# -eq 0 ; then
grep "^#" $0 | grep -v /bin/sh | sed -re "s/^#\s*//" >&2
exit 1
fi
$@ 2>&1 | logger ${LOGGER}