Elektra  0.9.4
Logging

Both code comments and assertions are unfortunately not very popular. A quite efficient way to still get some documentation about the code are logging statements. In Elektra they are currently inconsistent and unusable. Thus there is an urge for this decision.

Provide a Macro

ELEKTRA_LOG (int module, const char *msg, ...);

that calls

elektraLog ([as above], const char * function, const char * file,
const int line, ...);

and adds current function, file and line to elektraLog's arguments.

elektraLog is implemented in a separate log.c file. If someone needs filtering, logging to different sources or similar, he/she simply modifies log.c.

The severity passed to ELEKTRA_LOG_ should be as in syslog's priority, except the error conditions which are not needed (asserts should be used in these situations).

So we would have:

To add a new module, one simply adds his/her module to elektramodules.h via #define:

#define ELEKTRA_MODULE_<NAME> <SEQNUMBER>

The module name <NAME> shall be consistent with module names used in module: of src/error/specification.

A more complex system seems to be overkill. Thus libraries should not have any effects other than what is described by their API, logging should nearly always be disabled.

A more "hackable" logger seems to be more suitable for individual needs. Having a separate log.c means that the logger can be changed without the need to recompile anything but a single file. It also removes the dependency of stdio.h from every individual file to a single place.

Thus logging is very easy to use (only include elektralog.h and use ELEKTRA_LOG) and still very flexible (with modules, severity, file, line and function information nearly everything someone wants from a logging system can be achieved in log.c.

The current VERBOSE would be turned off forever and the code within VERBOSE needs to be migrated to ELEKTRA_LOG.