[dev] Logging changes for __FUNC__, errno and debug guards

David Lamparter equinox at diac24.net
Tue Apr 13 20:09:16 UTC 2021


Hi again all,


while the previous logging changes I've been working on have all been
non-intrusive - i.e. no touching any zlog_* or flog_* lines - there are
a few things I'd like to do at some point that do touch a lot of the
zlog_* lines:

- "factor out" strerror() / errno printing.  This is why "flog_err_sys"
  exists, it currently does the exact same thing as "flog_err" but the
  idea is that "flog_err_sys" is used when there's some system error and
  errno is valid.  The logging code would print strerror() automatically
  without this being a parameter.  And we can put errno into a keyword,
  like systemd-journald has with "ERRNO=".

  flog_err_sys is already being used in quite a bit of the code, but
  this would need some double checking, and the strerror() argument
  would be removed.

- "factor out" the __FUNC__ argument used on a lot of debug calls.  The
  logging code can prefix *all* debug messages with the calling function
  name, without this being an extra parameter to the call.  Also,
  RFC5424 and journald log targets can include the file/line/func
  information in the message metadata.

- the debug guards could use a dump of massage units too - assimilating
  the if() into the macro and getting rid of the indentation level.  We
  already have DEBUG*() in lib/debug.h plus debugf() in nhrpd/debug.h &
  babeld/util.h.  These 3 should be unified and zlog_debug() marked
  deprecated (i.e. warning on any unguarded debugs)

  A particular consideration for this last item is the "parametrized
  debugs", e.g. "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>"

A lot of this stuff can be done with coccinelle, but it'll be a large
and annoying change, so I'd like to discuss *what* and *when* to do it
here.

(For starters, the 2nd and 3rd thing should happen at the same time
since it's affecting most/all zlog_debug() calls.)

None of this is "urgent" and a lot could also be done in smaller steps,
e.g. converting babeld & nhrpd first.  I'd also make these non-breaking
changes as much as possible, i.e. have old & new forms both work for
some period of time.

Opinions & Comments?


-David



More information about the dev mailing list