mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00: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:
1 parent
56a3f6882b
commit
2681e4c01a
1 file changed
+12
-1
@@ -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