aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-05-23 02:18:13 +0300
committerCem Keylan <cem@ckyln.com>2020-05-23 02:18:13 +0300
commite2c7f071b338372b75b47e5a8f44a4b513bf3154 (patch)
tree0a6f0b97227ae6c7c597fb5613a14387de1042a4
parent3b3e6c6d519f8f5c262fab445449adfc79a6d694 (diff)
downloadinit-e2c7f071b338372b75b47e5a8f44a4b513bf3154.tar.gz
rc.lib: define logger at the beginning (if it exists)
-rw-r--r--rc.lib7
1 files changed, 6 insertions, 1 deletions
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}"
}