From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=stwcx.xyz (client-ip=66.111.4.28; helo=out4-smtp.messagingengine.com; envelope-from=patrick@stwcx.xyz; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=stwcx.xyz Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=stwcx.xyz header.i=@stwcx.xyz header.a=rsa-sha256 header.s=fm2 header.b=LveYnaqz; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=ew81Obqz; dkim-atps=neutral Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49c72r5j8RzDqS3 for ; Wed, 3 Jun 2020 09:06:44 +1000 (AEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 7FC035C00EC; Tue, 2 Jun 2020 19:06:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 02 Jun 2020 19:06:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stwcx.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=B7mUQe/m/QAwuYQEUvNnMsZaYMG jnigK7346HO98J3w=; b=LveYnaqzjnrLgz8xgf4HXws5QcUwoKNEV3HFT+qdGyx UyFdCO70an173r9aJxYa2KrU7pp3FGI/h6WxbvaBRgUU0LJTkTDxqMM5Jr5ADXOx eLkmRYwr+Q+WQFg6iBQc24utZMHJ43vSjyKnB5ubdCnhgXNaiXvP6OaavNlxH47t KBkmASBkJy/YBsDEUwHglF9T71HHNv4i/gvfygRq+lzfRTqlChEkGLP+yhDvF4Yx 3Vz7k4TKyqDRy/ZrI9FQBusCAL6aq0+qs5ZJPSNnCsHWffq8oXam3C0k5fwdCLAs EkVvADmgfog4KNQU+HuwOo20SKcvhsGXmGvCbDIqrow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=B7mUQe /m/QAwuYQEUvNnMsZaYMGjnigK7346HO98J3w=; b=ew81Obqz2QzNeh5KtGee9C yM4eYpUaIRwqJRyMer6XcdyUtSm6m/UGeDJGzr7jGKWmeFKT4FlNr2Puc9Nm2Izs El8yVTnJzh9nvziaOuxvERcSrROXhi1YCGIt8RfT/VzX5ULCZVwJUkPh7WFOLnLn T8Ts2Z5cI5kKb5C50KF+FNQ13k3LQ1ku+6rELqnE0pKfhJWW7QSIJKTM24OogEAr OvviRmFqePY4zHmD+qeuNGNUn+v5c7WTt/HJtVdX499NwUYfAYXD2NGapgj7aVqN FTv5pANka8YGj/llP7sDxECa3CwXcYHBF3I6B1k66F8CpkrmMe4zRGfVnnjNfGDA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudefkedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdlfeehmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtjeenucfhrhhomheprfgrthhrihgtkhcuhghilhhl ihgrmhhsuceophgrthhrihgtkhesshhtfigtgidrgiihiieqnecuggftrfgrthhtvghrnh epkeduuedtfeeihfehfeehfedvjeeujeeikedtteehledvhfelheekgedvieevkefhnecu kfhppeejiedrvdehtddrkeegrddvfeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepphgrthhrihgtkhesshhtfigtgidrgiihii X-ME-Proxy: Received: from localhost (76-250-84-236.lightspeed.austtx.sbcglobal.net [76.250.84.236]) by mail.messagingengine.com (Postfix) with ESMTPA id A197D3060FE7; Tue, 2 Jun 2020 19:06:40 -0400 (EDT) Date: Tue, 2 Jun 2020 18:06:39 -0500 From: Patrick Williams To: William Kennington Cc: =?utf-8?B?6YOB6Zu3?= , openbmc , Brad Bishop Subject: Re: OpenBMC Logging and Error Handling Dos and Don'ts Message-ID: <20200602230639.GK17541@heinlein> References: <4c4aa12b1ffde80ebbf49ad78b6046889f4226c0.camel@fuzziesquirrel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AYsPlKobQGgtCvjI" Content-Disposition: inline In-Reply-To: X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 23:06:45 -0000 --AYsPlKobQGgtCvjI Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 01, 2020 at 11:07:46PM -0700, William Kennington wrote: > If you use the fmt library it would only require one extra temporary stri= ng > to be constructed and it works trivially with something like phosphor > logging. >=20 > log(fmt::format("My error: {}", filename)); >=20 > It also has the advantage of understanding basic c++ types like > std::strings and std::string_views. >=20 > On Mon, Jun 1, 2020 at 8:33 PM =E9=83=81=E9=9B=B7 wrote: >=20 > > I have a bit concern about this. The existing phosphor-logging API > > does not support this well. > > Specifically, it does not support the "printf" way to generate a > > string with the variables to log. > > So previously we typically put the variables in entries. > > I do agree that logging the variables in the MESSAGE field is much bett= er. > > But to encourage such logging, the logging API should be enhanced to > > support the "printf" way. > > E.g. > > log("Something is wrong: %s:%d", xx, xxx); > > is much better than: > > std::string to_log =3D xxx; // generate the message manually > > log(to_log); > > > > Otherwise, it's really not convenient to write such logging code. > > Separate from this proposal from Brad, I'd like to work on a next-generation of phosphor-logging. When we originally implemented phosphor-logging we were all pretty new to C++14. I think there can be some great improvement in the syntax of phosphor-logging now that we have C++17 (and more experience). The biggest change I'd like to do is in the way the structured entries are defined, but I think we can improve the verbosity of syntax in making a log in general. Some example syntax: // Current syntax (and I'm being especially verbose on the namespaces). phosphor::logging::log("Some message", phosphor::logging::entry("EXAMPLE=3D%s"), example_str); // Potential syntax lg::error("Some message", "EXAMPLE"_s, example_str); In a code-review I was on, we had some discussions about how difficult it is to create data that isn't in the "-o verbose" and I think William and Lei are both referring to that as well. I am concerned that a generic format leads us more to unstructured logging, which personally I don't like. My suggestion is that we have some easy syntax to indicate "also put this structured data into the raw message" so that my example above the message becomes "Some message. EXAMPLE=3D'the string'". I'd be interested to hear what "next generation logging" others have in mind. --=20 Patrick Williams --AYsPlKobQGgtCvjI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEBGD9ii4LE9cNbqJBqwNHzC0AwRkFAl7W230ACgkQqwNHzC0A wRl3qQ//Y9Zrtmxmdu0qoT9zBvi7UbL0UqJi/GcavHbUGoGQBiYZwYQ/CTbLBz8b NSPibtpLcNf7zljD7rJ8tD0oKFRWvTqPtJlp2/OabgfNc5fpJwS28CjTJ5TS5ONG 7y1GREPmENB8biE1E1wyq0RCkM4XpOF+X2Fi5+aVErjCqX6uSYB+cx+cdKGg2xmC DTavOUyJGdojJkVluYcG6Wu/mcZPjo5e6M4DhYjI6rfBMm02z0s6896+0zfhxlF9 i5kLyQ5NNqXkHmIQYazXoRMDgAyY65zS64Qnpm3Uca6cLtN1KI4g5qYiFVaLfest OBABG7wH21HdEkO8bktwNtlfLb1AzgT/6dyzrAA/mNQ5iqO+D7GYb9KQSIyE+GeY 38GBS1Yk9iyqHTMNX4npyIE4MilqSUcqqU6X5CTR+JMlAEHoFZ7mjU+jtM/IAooa OWAywtUGRwHOWNaHUgj44pYwz1QyUF8iyFtrTpQTwSNjlgKjcZiIrenQrfA9YS2N xu/3S8R+z6ayGzKuvr7NTTB5pS/HoG0+j6zMxpsUHq4+d4IHfQfA9KMSB5GKFKZe i0ZoQPNhrSEtH5s5MFT6Jcl4yfKKBaxTOhFeANz76sTURmqBzF9zdXY346qnAwia LyUIYLdkt2/a+yFDXH4IgdshzZ6IN9SStI22yWC7RqGGp650oIA= =BIG8 -----END PGP SIGNATURE----- --AYsPlKobQGgtCvjI--