Date: Thu, 26 Mar 2015 22:20:13 -0500 From: Eric Badger <eric@badgerio.us> To: freebsd-current@freebsd.org Subject: Early use of log() does not end up in kernel msg buffer Message-ID: <5514CC6D.3020607@badgerio.us>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------000906090006050703080907 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Using log(9) when no process is reading the log results in the message going only to the console (contrast with printf(9), which goes to the console and to the kernel message buffer in this case). I believe it is truer to the semantics of logging for messages to *always* go to the message buffer (where they can eventually be collected and in fact put into a logfile). I therefore propose the attached patch, which sends log(9) to the message buffer always, and to the console only if no one has yet opened the log. It may be more complete to log to the console only if the log level is greater than some (user defined) value, but this seems like that might be more than necessary for this case. Thoughts? Eric --------------000906090006050703080907 Content-Type: text/x-patch; name="log.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="log.diff" diff --git share/man/man9/printf.9 share/man/man9/printf.9 index 84ac822..505ea9b 100644 --- share/man/man9/printf.9 +++ share/man/man9/printf.9 @@ -67,7 +67,8 @@ The .Fn log function sends the message to the kernel logging facility, using the log level as indicated by -.Fa pri . +.Fa pri , +and to the console if no process is yet reading the log. .Pp Each of these related functions use the .Fa fmt diff --git sys/kern/subr_prf.c sys/kern/subr_prf.c index 7e6fd09..6509522 100644 --- sys/kern/subr_prf.c +++ sys/kern/subr_prf.c @@ -295,7 +295,7 @@ log(int level, const char *fmt, ...) va_list ap; va_start(ap, fmt); - (void)_vprintf(level, log_open ? TOLOG : TOCONS, fmt, ap); + (void)_vprintf(level, log_open ? TOLOG : TOCONS | TOLOG, fmt, ap); va_end(ap); msgbuftrigger = 1; --------------000906090006050703080907--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5514CC6D.3020607>