From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGp1Q-0004o7-76 for qemu-devel@nongnu.org; Mon, 02 May 2011 05:02:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QGp1P-00046m-9C for qemu-devel@nongnu.org; Mon, 02 May 2011 05:02:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGp1P-00043l-0l for qemu-devel@nongnu.org; Mon, 02 May 2011 05:02:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4292Pqd007053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 May 2011 05:02:25 -0400 Received: from rincewind.home.kraxel.org (vpn2-9-136.ams2.redhat.com [10.36.9.136]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4292Nlg019570 for ; Mon, 2 May 2011 05:02:24 -0400 Message-ID: <4DBE731E.1050905@redhat.com> Date: Mon, 02 May 2011 11:02:22 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1303979358-4421-1-git-send-email-alevy@redhat.com> <1303979358-4421-4-git-send-email-alevy@redhat.com> <4DBAAA92.60409@redhat.com> <20110429221944.GD13837@amber.local> In-Reply-To: <20110429221944.GD13837@amber.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] debug logging (was: Re: [PATCHv2 3/4] qxl: add debug_cs and cmdlog_cs) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, > The bigger hack called "qxl_terse" I didn't even send :) ok, so now I get > to either keep this in my closet or think of how to do a minimal acceptable > qemu logging infrastructure that would let me register a logging handle and > use that to redirect to a chardev (they would all default to being muxed over > stdio?) > > QemuLogger *qemu_create_logger(const char *logger_id); > - logger_id is used to match to the chardev given on the command line > - need to prevent collision, so probably easier to have a logger_id be an int > and have that looked up to a string in an automatically generated table? What I have in mind is a simple dbg_print() function, integrated with qdev and simliar to what the linux kernel has, i.e. something like: int dbg_print(DeviceState *qdev, int loglevel, const char *fmt, ...); This can basically be used that as drop-in replacement for the fprintf(stderr, fmt, ...) style found in many drivers. dbg_print would get the driver name via qdev->info->name, get the instance via qdev->parent_bus->info->get_dev_path(), get a timestamp, then create a standard prefix for all messages for easy grepping. It would also check qdev->loglevel to figure whenever the message should be printed or not. All devices get a property to set qdev->loglevel, so all logging can be configured at runtime per device. Messages go to stderr by default. A -debug switch could be added to route them another way. Comments in the idea? cheers, Gerd