common: LogEntry: add clog_type_to_string()

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
common: LogEntry: add 'channel' field

We now introduce the concept of 'channel', analogous to syslog
facilities, for log entries.  This will, shortly, allow a LogClient
to send messages to more than just the default syslog facility and log
file, also allowing multiple LogClients and having a way to associate
a LogEntry with its rightful owner.

We also add the same field to the MLogAck message so that a LogClient
waiting on a given ack is able to recognize the MLogAck as its own.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
common: LogEntry: refactor how we output to syslog

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
common: LogClient: delegate message reference release to caller

Caller decides whether to release the message's reference.  It may want
to use the same message on another LogClient, if we decide not to handle
it.

Currently we always handle the message and thus always return true.  This
will not be as such later in the patch series.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
common: str_map: get value from map for given key

We add a helper function for a k/v string map so that obtaining a value
from it doesn't become a tedious task.  This function behaviour maps
that of 'get_str_map()'.  As such, we pass a map of string -> string,
the 'key' we're looking for and a 'default value' that's to be returned
in case there is no such key in the map.

The function will return:

- 'default value' if there's no such key.
- 'key' if map['key'] is an empty string
- map['key'] otherwise

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
common: LogClient: allow specifying facility for LogClient

Instead of allowing only one LogClient, we will now allow any daemon to
have any number of LogClients.  They may either all log to the default
facility and level, or they may see their facility and level specified
upon creation (via a new constructor).

This patch also changes 'handle_log_ack' in such a way that the LogClient
will handle all acks with bearing the LogClient's facility, or will
otherwise simply ignore them.  The function will return true whenever the
message has been handled or false if that was not the case.  It will fall
on the caller the responsibility of deciding whether the message will be
passed to other LogClients or not, and when it is to be release.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Monitor: init clog to output to syslog (or not)

The LogClient has changed in a way that it is now feasible having more
than one LogClient per daemon/client.  As such, the LogClient can no
longer rely on daemon/client-specific boolean values to know whether it
should log stuff to syslog or not.  Instead of breaking API
compatibility, we now delegate to the user of LogClient the
responsibility of informing LogClient on whether it should or should not
log to syslog.  Therefore we need to have the monitor setting 'clog' to
whatever value is in conf->clog_to_syslog.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Monitor: log every administrative action in an 'audit log'

Fixes: #7988

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Monitor: log administrative actions via admin socket

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Monitor: propagate return for functions called for admin socket

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Monitor: observe log client config changes

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
FIXUP: common: config_opts.h: change 'default' channel to 'cluster'

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
DNM: mon: LogMonitor: manage multiple channels creatively

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: LogMonitor: observe config changes

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>