Logging

Logging — Logging in MAFW

Synopsis

void                mafw_log_init                       (gchar const *doms);
#define             g_info                              (...)

Description

Users of MAFW can enable the display of log and informational messages selectively in run-time. To do so you need to invoke mafw_log_init(), which takes a string describing what levels of messages to log; others are all disabled. You can override this compile-time specification by setting the $MAFW_LOG environment variable.

The specification string is like "[domain]:level[,[domain]:level]*", where `domain' is the log_domain argument of g_log, and `level' is either "ERROR", "CRITICAL", "WARNING", "MESSAGE", "INFO", "DEBUG", "ALL", "PRINT" or "-" (lettercase is not taken into account) telling the minimum required urgency of messages to be logged (ie. don't log less important messages).

"-" means don't log anything from that domain. If `domain' is "default" `level' applies to all messages for which G_LOG_DOMAIN wasn't defined. Otherwise if the `domain' part is empty `level' will apply to domains not specifically mentioned in the string.

All possible values of `level' except "ALL" and "PRINT" makes g_print() silent. If `level' is "ALL" the domain is effectively ignored by the filtering mechanism (ie. it's processing is left as it was). "PRINT" is like "-", but leaves g_print() enabled.

Some examples:

# silence everything
MAFW_LOG=":-" ./app
# silence 'foo'
MAFW_LOG="foo:-" ./app
# only mafw messages less important than message
MAFW_LOG="mafw:warning" ./app
# all from mafw-dbus
MAFW_LOG="mafw-dbus:debug" ./app

Details

mafw_log_init ()

void                mafw_log_init                       (gchar const *doms);

Disables the display of all log messages except those matching doms, whose format is described in the section introduction. If doms is NULL, a sane default is used. If it's empty no changes will be made to logging.

Note

This function works as expected only for the first time invoked and only if no log handlers were set before because there's no way clearing out log handlers in general.

doms : the doms. If the $MAFW_LOG environment variable is defined, its value overrides this parameter

g_info()

#define             g_info(...)

Convenience macro to log at INFO level. It receives a format string, followed by parameters to insert into the format string (as with printf())

... : List of parameters.