From owner-freebsd-current@FreeBSD.ORG Mon Apr 6 20:18:28 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 63EAE158 for ; Mon, 6 Apr 2015 20:18:28 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35B1CEAA for ; Mon, 6 Apr 2015 20:18:28 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 4EAAFB953; Mon, 6 Apr 2015 16:18:27 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Subject: Re: Early use of log() does not end up in kernel msg buffer Date: Mon, 06 Apr 2015 15:49:44 -0400 Message-ID: <2033248.Eu3RHS8lTG@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <5514CC6D.3020607@badgerio.us> References: <5514CC6D.3020607@badgerio.us> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 06 Apr 2015 16:18:27 -0400 (EDT) Cc: Eric Badger , 'Poul-Henning Kamp' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2015 20:18:28 -0000 On Thursday, March 26, 2015 10:20:13 PM Eric Badger wrote: > 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? I think phk@ broke this back in 70239. Before that the log() function did this: log() { /* log to the msg buffer */ kvprintf(fmt, msglogchar, ...); if (!log_open) { /* log to console */ kvprintf(fmt, putchar, ...); } } I think your patch is fine unless phk@ (cc'd) has a reason for not wanting to do this. -- John Baldwin