$darkmode
Elektra 0.11.0
|
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.
ENABLE_LOGGER=OFF
Provide a Macro
that calls
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 have:
ELEKTRA_LOG_WARNING
: warning conditionsELEKTRA_LOG_NOTICE
: normal, but significant, conditionELEKTRA_LOG_INFO
: informational messageELEKTRA_LOG_DEBUG
: debug-level messageTo add a new module, one simply adds his/her module to elektramodules.h
via #define
:
The module name <NAME>
shall be consistent with module names used in module:
of src/error/specification
.
A more complex system is 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.
elektralog.h
and use ELEKTRA_LOG
)The current VERBOSE would be turned off forever and the code within VERBOSE needs to be migrated to ELEKTRA_LOG
.
See CODING.md for recommendations how to use the logger.