mirror of
https://github.com/troglobit/finit.git
synced 2026-11-30 21:18:22 +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
+11
@@ -188,6 +188,17 @@ void logit(int prio, const char *fmt, ...)
|
|||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (!_slup && !fexist("/dev/log")) {
|
if (!_slup && !fexist("/dev/log")) {
|
||||||
|
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);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user