From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yo1ld-0006ra-PH for qemu-devel@nongnu.org; Thu, 30 Apr 2015 23:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yo1la-0002AN-JR for qemu-devel@nongnu.org; Thu, 30 Apr 2015 23:37:33 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:46832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yo1la-0002AI-Eo for qemu-devel@nongnu.org; Thu, 30 Apr 2015 23:37:30 -0400 Received: from /spool/local by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 30 Apr 2015 23:37:28 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id D0A9CC90041 for ; Thu, 30 Apr 2015 23:28:34 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t413bQ6G57344240 for ; Fri, 1 May 2015 03:37:26 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t413bPMh007258 for ; Thu, 30 Apr 2015 23:37:26 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <20150501012923.GH24886@voom.redhat.com> References: <20150501012923.GH24886@voom.redhat.com> Message-ID: <20150501033721.25451.62182@loki> Date: Thu, 30 Apr 2015 22:37:21 -0500 Subject: Re: [Qemu-devel] qemu-ga and logging domain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-devel@nongnu.org Quoting David Gibson (2015-04-30 20:29:23) > Michael, > = > I was just looking at some of the logging stuff in qemu-ga, and it > seems to be doing something very odd with the "domain". > = > static void ga_log(const gchar *domain, GLogLevelFlags level, > const gchar *msg, gpointer opaque) > { > GAState *s =3D opaque; > GTimeVal time; > const char *level_str =3D ga_log_level_str(level); > = > if (!ga_logging_enabled(s)) { > return; > } > = > level &=3D G_LOG_LEVEL_MASK; > #ifndef _WIN32 > if (domain && strcmp(domain, "syslog") =3D=3D 0) { > syslog(LOG_INFO, "%s: %s", level_str, msg); > } else if (level & s->log_level) { > #else > if (level & s->log_level) { > #endif > g_get_current_time(&time); > fprintf(s->log_file, > "%lu.%lu: %s: %s\n", time.tv_sec, time.tv_usec, level_str= , msg); > fflush(s->log_file); > } > } > = > This is sending messages to syslog instead of a logfile if domain is > set to "syslog". But the log domain is usually about where the > messages came from, not where they're going. > = > What's up with this? Hmm, good question... IIRC I originally wanted a way to extend GLogLevelFlags to support a syslog log-level, but failing that I ended up re-purposing the unused domain field as a sort of hack instead. As for why I felt the need to have slog() hook into this instead of calling syslog() directly... I think maybe I wanted to avoid having a global GAState *s in the qga/command* code for ga_logging_enable(s), but that could simply be done by having the slog() implementation live in qga/main.c. Then we can drop the need to re-purpose g_logv()'s 'domain' field. > = > -- = > David Gibson | I'll have my music baroque, and my code > david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _othe= r_ > | _way_ _around_! > http://www.ozlabs.org/~dgibson