[Swan-dev] where do log messages go

Andrew Cagney andrew.cagney at gmail.com
Wed Oct 17 17:31:19 UTC 2018


Following on from a discussion last week - this is an overview of all
the different places that messages can be sent.

In the below:

- 'whack at level RC' means send the output to whack with RC encoded
as an NNN prefix - yes those magic prefixes
- 'if connected, whack' means apply some heuristic to decide if the
message should go one of the connected whacks; for instance, not a
thread, state has an attached whack, ...
- I've tried the list the most common interface names (for each
there's a buffered alternative, but that is a separate discussion)
- threads can send messages to syslog but not whack
- syslog might, in fact be a file

Broadly, pluto sends messages to:

   syslog (system)
   whack (console)
   syslog+whack

but each case is tweaked using different log-levels, rc-levels and prefixes:

- from pluto to syslog(LOG_WARNING) and, if connected, whack(RC_LOG)
  for instance: plog(), libreswan_log()
  this is the most common case
  why is this at LOG_WARNING and not LOG_NOTICE or LOG_INFO?

- from pluto to syslog(LOG_WARNING) and, if connected, whack($RC)
  for instance: ploglog(RC, ...), libreswan_log_rc()
  this gets used to send the @*($&)(*! state numbers to whack
  why is this at LOG_WARNING and not LOG_NOTICE or LOG_INFO?

- from pluto to syslog(LOG_ERR) and, if connected, whack(RC_LOG_SERIOUS)
  for instance: LOG_ERRNO(), EXIT_LOG_ERRNO(), pexpect(), passert()
  I really wonder about LOG_ERRNO() - its use seem to be arbitrary
  if pluto is crashing, should this be LOG_CRIT?

- from pluto to, presumably if connected and only, whack($RC)
  for instance: whack_log(RC,...)
  calling this from a thread makes no sense (and will panic)

- from pluto to, presumably if connected and only, whack but with _no_
NNN prefix!!!
  for instance: whack_log_comment(...) / LSWLOG_INFO(buf)
  don't confuse this with whack_log(RC_COMMENT, ...) which _does_ add
the !(*#$)*( NNN prefix
  calling this from a thread makes no sense (and will panic)
  should it be called something like console_log() since the intent is
to send stuff to the user's attached console, else be silent

- from pluto to syslog(LOG_DEBUG) (not whack)
  for instance: DBGF(...), DBG_log(), ...

to me the obvious first step is to dump the NNN prefix embedded in
whack's output

The utilities, such as whack, are similar to pluto in that output can go to:

    stdout (console)
    stderr (errors, if enabled logging)

but with less twists:

- unconditionally to stdout
  for instance: printf(...) / LSWLOG_INFO() in library code
  should it be called something like console_log() since the intent is
to send stuff to the user's attached console, else be silent

- unconditionally to stderr
  for instance: fprintf(stderr, ...), LOG_ERRNO() / LSWLOG_ERROR() in
library code

- conditionally to stderr (typically library code)
  for instance: libreswan_log() when log_to_stderr==true
  for instance: DBG() when cur_debuging flags are set

as an example there's algparse which has options to control behaviour:
  algparse ike=xxx
  algparse --verbose ike=xxx
  algparse --debug ike=xxx
it's obvious problem is with --verbose which lists all algorithms -
that's a bug though - listing algorithms should be an explicit call
and not a side effect of initialization

Andrew


More information about the Swan-dev mailing list