From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202408 header.b=PKq3CjEK; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7EAFF5A004E for ; Thu, 05 Sep 2024 02:35:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202408; t=1725496522; bh=R+aXsbQ2AcgRx+I4kyMuLAGbhUIx5K6I8+hQJL5ZBQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PKq3CjEKiLL9ibzVvD+ibN/ziaF5RM+ufXj6nZe5DvK0aPzSO9SYUL6IP61ik+3ST PMtdzPr6H9nQYUGOaNhs87Aw2v09tAT1RRV2QGfsoc9tWf66nJtC74U62+QpOB6g4q hg7eAaCQbYi5YT6p2IIqHT1I3EteGmNb0jTr67El4vWeaHHJ7YUTHnWmMulD5ks2Gh hqrvN5RHCP6Qx+S3KBjSQe4Fj0uAmQwilmT7VCbGT96xRL6oLzfzUVYtzvaIrCK95O QQyFcBi2YnNuOWkMDhr78nIgcxYCcGK0fSWfHWPfWhMhNnOXzd48ekbNVQa+PIYsGK DQVVW+spwfniA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WzgPQ3pNRz4wbv; Thu, 5 Sep 2024 10:35:22 +1000 (AEST) Date: Thu, 5 Sep 2024 10:27:36 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] log: Don't prefix log file messages with time and severity if they're continuations Message-ID: References: <20240904142957.3713878-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="npVITlg0t4VuSkRa" Content-Disposition: inline In-Reply-To: <20240904142957.3713878-1-sbrivio@redhat.com> Message-ID-Hash: 35X4RM7XIKB3OXMRBC3ZRDVUJK2SKLVW X-Message-ID-Hash: 35X4RM7XIKB3OXMRBC3ZRDVUJK2SKLVW X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, AbdAlRahman Gad X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --npVITlg0t4VuSkRa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 04, 2024 at 04:29:57PM +0200, Stefano Brivio wrote: > In fecb1b65b1ac ("log: Don't prefix message with timestamp on --debug > if it's a continuation"), I fixed this for --debug on standard error, > but not for log files: if messages are continuations, they shouldn't > be prefixed by timestamp and severity. >=20 > Otherwise, we'll print stuff like this: >=20 > 0.0028: ERROR: Receive error on guest connection, reset0.0028: ERROR= : : Bad file descriptor >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > log.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) >=20 > diff --git a/log.c b/log.c > index 433b552..a61468e 100644 > --- a/log.c > +++ b/log.c > @@ -224,19 +224,23 @@ static int logfile_rotate(int fd, const struct time= spec *now) > /** > * logfile_write() - Write entry to log file, trigger rotation if full > * @newline: Append newline at the end of the message, if missing > + * @cont: Continuation of a previous message, on the same line > * @pri: Facility and level map, same as priority for vsyslog() > * @now: Timestamp > * @format: Same as vsyslog() format > * @ap: Same as vsyslog() ap > */ > -static void logfile_write(bool newline, int pri, const struct timespec *= now, > +static void logfile_write(bool newline, bool cont, int pri, > + const struct timespec *now, > const char *format, va_list ap) > { > char buf[BUFSIZ]; > - int n; > + int n =3D 0; > =20 > - n =3D logtime_fmt(buf, BUFSIZ, now); > - n +=3D snprintf(buf + n, BUFSIZ - n, ": %s", logfile_prefix[pri]); > + if (!cont) { > + n +=3D logtime_fmt(buf, BUFSIZ, now); > + n +=3D snprintf(buf + n, BUFSIZ - n, ": %s", logfile_prefix[pri]); > + } > =20 > n +=3D vsnprintf(buf + n, BUFSIZ - n, format, ap); > =20 > @@ -278,7 +282,7 @@ void vlogmsg(bool newline, bool cont, int pri, const = char *format, va_list ap) > =20 > va_copy(ap2, ap); /* Don't clobber ap, we need it again */ > if (log_file !=3D -1) > - logfile_write(newline, pri, now, format, ap2); > + logfile_write(newline, cont, pri, now, format, ap2); > else if (!(log_mask & LOG_MASK(LOG_DEBUG))) > passt_vsyslog(newline, pri, format, ap2); > =20 --=20 David Gibson (he or they) | 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 --npVITlg0t4VuSkRa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmbY+vMACgkQzQJF27ox 2GdY0A//T7mpTu/ONUw9CJKMcjTAbm5ZsXiwnNpMnZ9BNhq3pwMoBvrsO/X3rnFA MPtTkCl4aKHD8cZrEp4k7UVrWgUMsvJYBFqtF+vKtRt1RE0XVV3tPgm1J6ABIevS pz/0oidu6FZkK+Hb9UcdjV4J76Q64Gyq4B4LQn9O2kP9R+i1E6Bz1VxCC7y4D0/X RanoDbTmvoH4C+O7MyQQxeVdXBzMzdlyhaMKrosccFm/JUOREmiAVZZXsDTwPFlU IwBHMepOOwosQ4TiyFhp93IwIfwuMCfKyi6wqNoX4bNIIuVECzrKdUWgpwjroQPp xGUTqf11FRavq6SRuxTPJXGCkKfroclMTY6lvzdoQckU8QyPenRi3j2kLwD/2Atz lV5I8ROcURGn3oflVSL1P3UEiCWK59f4ek9q3xdmSLdXRYitKptHvYuLbagJTChi 469A+nrcGs2JEfOouYuMV3Xw3qCLrsJSOc5Uvu0I/UANZyW1WHP5ZIcibZ55c3fm GREETCLgTUgfM6SJuTORaXo+EmRr4pzxcCjtvYABRDqRqeMR6n+6Ah5lYU9m1S1t +7JfIs79RdDSYKomr2VNXms5GlABu/dAdkQrWsXERVLvbjl2D5t4bOdWXSVvmMZo 9ZE8fi8Ef5gjINtMd1DkrOfjeB/lpohvBZfPH5AEwMxXk4A3H2c= =yRQj -----END PGP SIGNATURE----- --npVITlg0t4VuSkRa--