From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yppjl-0001jW-Os for qemu-devel@nongnu.org; Tue, 05 May 2015 23:11:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yppji-0002qK-3T for qemu-devel@nongnu.org; Tue, 05 May 2015 23:11:05 -0400 Received: from ozlabs.org ([103.22.144.67]:35577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yppjh-0002pp-Nm for qemu-devel@nongnu.org; Tue, 05 May 2015 23:11:02 -0400 Date: Wed, 6 May 2015 13:10:54 +1000 From: David Gibson Message-ID: <20150506031054.GB1407@voom.redhat.com> References: <20150501012923.GH24886@voom.redhat.com> <20150501033721.25451.62182@loki> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Y7xTucakfITjPcLV" Content-Disposition: inline In-Reply-To: <20150501033721.25451.62182@loki> Subject: Re: [Qemu-devel] qemu-ga and logging domain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: qemu-devel@nongnu.org --Y7xTucakfITjPcLV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 30, 2015 at 10:37:21PM -0500, Michael Roth wrote: > Quoting David Gibson (2015-04-30 20:29:23) > > Michael, > >=20 > > 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". > >=20 > > 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); > >=20 > > if (!ga_logging_enabled(s)) { > > return; > > } > >=20 > > 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_s= tr, msg); > > fflush(s->log_file); > > } > > } > >=20 > > 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. > >=20 > > What's up with this? >=20 > 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. >=20 > 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. That sounds like a better idea to me. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --Y7xTucakfITjPcLV Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVSYY+AAoJEGw4ysog2bOSTg0P+wRnJ+amen6YsCyR6gBaZHzP qHpGrDKpc0hGgVTEbvRFUMluuTjPLpkOuKOJuXGC76Wr01TZ7O+/rDl+Ihk3MBHv TPXVjH0UPJ0V5aUsKisdsXtL/hk7ee4rVdcV5MvJiKxem0ifTpZ3jVn0XNNTTarZ LWwP+f3WaXJ/ToJTEO7Wd6SzTJzxYgSxcAZK3LOlNcuGdylJTio1Wj/PTvEwdvGb ygjQn+WXjNWyNNTcsT+ls876s29EpjIZthPnlSE2MtCww1vMD3GLnKD03Jt9mlar c9kL3IaIIRP7irelOuw6kZXYknk6Bzl2kmpXpPF84GXo0AMr7ztyNTPq/dlB5oew LqT58E/kGIfjrcbdzPummphFurUB2B1YNIAzF556zSKweCYYwkC04F3nrFggkfZF UP5iXuqsKWBHvuvDBASIQCYS9xXu1UVWgYQCz71An/DpMdl+QagfDmgZe4/BNG9k 47wPNnTQ05Jno96vdzOsmSuPOnHfZW5Ev+FWdJBdFYyYZoEQ5bcc07YL+WOHZ2+9 b6XTPFem9gUpTvBfWi3VjJFeb0V3/C92b9fkOgfqNJCObmbikd3DLUPE77pEwDOm BD/bpSRF7EXeWXV3EhGgqdmVxnaRrq1Jmvg+kVShJ3qq0BmnSvCXIwSVyTnGgcLS qQPP3JAR8WYacCOgfdta =93rm -----END PGP SIGNATURE----- --Y7xTucakfITjPcLV--