mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
Add early logging support to /dev/kmsg
Very early, before syslogd has started, we have traditionally been forced to use stdout/stderr for debug, warning and error messages. With this patch we can now rely on /dev/kmsg to preserve all logs from early Finit problems. When syslogd/klogd starts up they read /dev/kmsg and copy logs to /var/log/* files. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -188,7 +188,18 @@ void logit(int prio, const char *fmt, ...)
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (!_slup && !fexist("/dev/log")) {
|
||||
vfprintf(stderr, fmt, ap);
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen("/dev/kmsg", "w");
|
||||
if (fp) {
|
||||
fprintf(fp, "<%d>finit[1]: ", LOG_DAEMON | prio);
|
||||
vfprintf(fp, fmt, ap);
|
||||
fclose(fp);
|
||||
} else {
|
||||
fprintf(stderr, "Failed opening /dev/kmsg for appending ...\n");
|
||||
}
|
||||
if (prio <= LOG_ERR)
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user