From e2c7f071b338372b75b47e5a8f44a4b513bf3154 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Sat, 23 May 2020 02:18:13 +0300 Subject: rc.lib: define logger at the beginning (if it exists) --- rc.lib | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rc.lib b/rc.lib index ef18aff..8fa85bf 100644 --- a/rc.lib +++ b/rc.lib @@ -3,6 +3,11 @@ export PATH=$PATH:/usr/local/bin:/usr/bin +# logger is provided by 3 packages on the core repository (sbase, +# busybox, util-linux). However, it is optional. Since logger +# outputs to stderr, we cannot silence stderr to not display error +# messages in the rare case where it isn't available on the system. +logger=$(command -v logger) || logger=: log() { # A function to log all output to syslog (if it is available) @@ -22,7 +27,7 @@ log() { # standard input for the log. This means you can pipe the output # of a command to this function. Those will be logged as well. [ "$1" ] && printf 'init: %s\n' "$@" >/dev/kmsg 2>/dev/null - logger -t init "${@:--s}" + "$logger" -t init "${@:--s}" } -- cgit v1.2.3