All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Williams <patrick@stwcx.xyz>
To: Andrew Jeffery <andrew@aj.id.au>
Cc: OpenBMC List <openbmc@lists.ozlabs.org>
Subject: Re: `phosphor-logging` APIs (RFC)
Date: Wed, 28 Jul 2021 21:53:07 -0500	[thread overview]
Message-ID: <YQIYE4yH7IcGIrjd@heinlein> (raw)
In-Reply-To: <e1b41c2e-bcad-4282-a3b9-8f5344cab056@www.fastmail.com>

[-- Attachment #1: Type: text/plain, Size: 3141 bytes --]

On Thu, Jul 29, 2021 at 09:04:14AM +0930, Andrew Jeffery wrote:
> I've left a comment on the patch:
> 
> https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-logging/+/45310/1/docs/structured-logging.md#60
> 
> But duplicating that here, how I'd like to use the API and what I'd 
> like to see in the resulting journal message is:
> 
> ```
> value = "xyz.openbmc_project.EntityManager";
> lg2::error("Error talking to {ENTITY} error code is {ERRNO}", "ENTITY", value, "ERRNO", 2);
> ```

Thanks for the description.  What you've proposed is at least able to be
compiled and wouldn't increase the call-site code footprint at all.  It would
have more work in the [common] code that translates from the lg2 API format to
systemd, but it isn't outrageous and is fairly straight-forward to implement
at this point.

So far there are 3 approaches on the table:

```

a. Yours.

  error("Hit {ERROR} during {STAGE}.", "ERROR", "bad foobar", "STAGE",
        "baz-grae", "EXTRA", 123);

->

  MESSAGE="Hit bad foobar during baz-grae."
  ERROR="bad foobar"
  STAGE="baz-grae"
  EXTRA=123

b. opt-in processing

  error("Hit error during processing.", "ERROR", primary, "bad foobar",
        "STAGE", primary, "baz-grae", "EXTRA", 123);

->

  MESSAGE="Hit error during processing. ERROR=bad foobar STAGE=baz-grae"
  ERROR="bad foobar"
  STAGE="baz-grae"
  EXTRA=123

c. opt-out processing

  error("Hit error during processing.", "ERROR", "bad foobar", "STAGE",
        "baz-grae", "EXTRA", quiet, 123);

->

  MESSAGE="Hit error during processing. ERROR=bad foobar STAGE=baz-grae"            
  ERROR="bad foobar"                                                                 
  STAGE="baz-grae"                                                              
  EXTRA=123 

```

Based on my experience trying to apply lg2 to a reasonable sample[1], (b)
seems rather verbose.  We're going to end up with most developers just
adding a `primary` on each data entry anyhow, so it is kind of pointless.

Both (a) and (c) are relatively succinct.  (a) has the advantage of being
slightly more human-friendly, but at a disadvantage of worse performance and
redundant tag identification (which cannot be checked at compile time either).
(c) is faster, has no redundancy, and is consistently structured, but is
slightly less human readable.

My question would be is if (a) is really that much better from a human
perspective to warrant the extra processing and redundancy (and thus potential
programming errors introduced by tag mismatches)?  To me, (c) provides all the
same information with only minimal readability impact and certainly better
performing.

> Better yet would be if we could just forward the format string and 
> journalctl renders this at invocation time, but we'd need to work with 
> upstream on that.

I kind of doubt they'd be interesting in absorbing this kind of string
formatting into the library, but maybe I'm wrong.

1. https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-virtual-sensor/+/45353/1/virtualSensor.cpp 

-- 
Patrick Williams

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-07-29  2:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 20:24 `phosphor-logging` APIs (RFC) Patrick Williams
2021-07-28  5:52 ` Andrew Jeffery
2021-07-28  6:25   ` Patrick Williams
2021-07-28 23:34     ` Andrew Jeffery
2021-07-29  2:53       ` Patrick Williams [this message]
2021-08-03  0:27         ` Patrick Williams
2021-08-03  4:07           ` Andrew Jeffery

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YQIYE4yH7IcGIrjd@heinlein \
    --to=patrick@stwcx.xyz \
    --cc=andrew@aj.id.au \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.