aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-05-23 02:16:54 +0300
committerCem Keylan <cem@ckyln.com>2020-05-23 02:16:54 +0300
commit98213de7e5bc3c22c196cfa3d3fa4ddcc1106456 (patch)
treef4c21b63d5c2d90469b82e87e4302f7cf7cd2aa2
parent237b3aa53bd2d67890a142ca7365e82a8c067216 (diff)
downloadinit-98213de7e5bc3c22c196cfa3d3fa4ddcc1106456.tar.gz
rc.lib: drop log_file variable
-rw-r--r--rc.lib26
1 files changed, 18 insertions, 8 deletions
diff --git a/rc.lib b/rc.lib
index 898bb1c..ef18aff 100644
--- a/rc.lib
+++ b/rc.lib
@@ -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
}