From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWXhI-0005ID-Q6 for qemu-devel@nongnu.org; Sun, 17 Jan 2010 11:09:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWXhD-0005Hu-11 for qemu-devel@nongnu.org; Sun, 17 Jan 2010 11:09:51 -0500 Received: from [199.232.76.173] (port=43550 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWXhC-0005Hr-Ra for qemu-devel@nongnu.org; Sun, 17 Jan 2010 11:09:46 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:57685) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NWXhC-0001XH-7d for qemu-devel@nongnu.org; Sun, 17 Jan 2010 11:09:46 -0500 Message-ID: <4B53363C.8060906@mail.berlios.de> Date: Sun, 17 Jan 2010 17:09:32 +0100 From: Stefan Weil MIME-Version: 1.0 Subject: [Qemu-devel] [RFC] Don't send local debug output to stdout (was: pm_smbus: remove #ifdef DEBUG) References: <1262745591-28697-1-git-send-email-yamahata@valinux.co.jp> <1262745591-28697-25-git-send-email-yamahata@valinux.co.jp> <4B447724.6070708@mail.berlios.de> <20100106235113.GE29412@valinux.co.jp> In-Reply-To: <20100106235113.GE29412@valinux.co.jp> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers Cc: Isaku Yamahata Isaku Yamahata schrieb: > On Wed, Jan 06, 2010 at 12:42:28PM +0100, Stefan Weil wrote: >> Isaku Yamahata schrieb: >>> remove #ifdef DEBUG by using macro. >>> >>> Signed-off-by: Isaku Yamahata >>> Acked-by: Gerd Hoffmann >>> --- >>> hw/pm_smbus.c | 21 ++++++++++++--------- >>> 1 files changed, 12 insertions(+), 9 deletions(-) >>> >>> diff --git a/hw/pm_smbus.c b/hw/pm_smbus.c >>> index 6ef6b9e..9929d72 100644 >>> --- a/hw/pm_smbus.c >>> +++ b/hw/pm_smbus.c >>> @@ -37,6 +37,15 @@ >>> #define SMBHSTDAT1 0x06 >>> #define SMBBLKDAT 0x07 >>> >>> +//#define DEBUG >>> + >>> +#ifdef DEBUG >>> +# define SMBUS_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) >> Debug output should go to stderr. So this would be even better: >> >> +# define SMBUS_DPRINTF(format, ...) fprintf(stderr, format, ## >> __VA_ARGS__) >> > > Yes, in general. > However the original code sends debug output to stdout and > Most of debug output goes to stdout than stderr. You can easily > see it by greping with DEBUG. > > So at this time, I'd like to send debug output to stdout. > (And hopefully later create a framework and make debug output go > to stderr consistently over sources.) You are correct: there is much code which writes debug output to stdout. When qemu is running in system mode with curses interface (-curses) or serial console only (-nographic), debug output and system output will be mixed on stdout. In many cases, this makes the output unreadable. Therefore I prefer a separate output channel for debug messages. The usual (and easiest) solution is directing them to stderr. This allows mixing normal and debug output (sometimes a useful feature) or separating them by using standard I/O redirection. A more advanced solution could provide special logging functions. Those could write debug messages to qemu.log (or some other file). Debug messages from drivers could be prefixed using the qdev driver name, we could support levels (info, warning, error, ....), more than one output channel - everything typical logging frameworks like log4c (or others) support. I suggest these steps: 1. Debug output to stdout is no longer accepted for new / modified code. 2. New or modified debug messages should go to stderr. 3. Patches which switch debug output from stdout to stderr are accepted. 4. We discuss whether debug output to stderr is sufficient or which logging framework should be used. Please note that I talk here about debug log messages which are activated by conditional compilation and which are disabled normally (not those going to qemu.log). Any comments are welcome. Kind regards, Stefan Weil