diff options
author | Cem Keylan <cem@ckyln.com> | 2020-05-23 02:16:54 +0300 |
---|---|---|
committer | Cem Keylan <cem@ckyln.com> | 2020-05-23 02:16:54 +0300 |
commit | 98213de7e5bc3c22c196cfa3d3fa4ddcc1106456 (patch) | |
tree | f4c21b63d5c2d90469b82e87e4302f7cf7cd2aa2 | |
parent | 237b3aa53bd2d67890a142ca7365e82a8c067216 (diff) | |
download | init-98213de7e5bc3c22c196cfa3d3fa4ddcc1106456.tar.gz |
rc.lib: drop log_file variable
-rw-r--r-- | rc.lib | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -3,15 +3,26 @@ export PATH=$PATH:/usr/local/bin:/usr/bin -log_file="${log_dir:=/var/log/init}/$(date +%Y%m%d-%H%M)-${0##*.}" log() { - [ "$log" = 1 ] || { - cat - return 0 - } - mkdir -p "$log_dir" - tee -a "$log_file" + # A function to log all output to syslog (if it is available) + # and to kernel messages. This way the logs are readable after + # reboot. + # + # The usability of this also depends on how early you start + # syslogd and how late you stop it. I will be modifying this + # to enable a way (or multiple ways) of storing boot/shutdown + # logs in a persistent manner. + # + # Right now, you could possibly start a syslogd from the early + # boot hooks which will be run right after filesystems are + # mounted. + # + # If no arguments for the logger are specified, it will read + # 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}" } @@ -71,7 +82,6 @@ parse_cmdline() { forcefsck) FORCEFSCK="-f" ;; fastboot) FASTBOOT=1 ;; loglevel=?) dmesg_level=${arg##*=} ;; - log) log=1 ;; esac done } |