$darkmode
Elektra 0.11.0
|
Enable logging by compiling with the CMake option ENABLE_LOGGER=ON
(e.g. cmake -DENABLE_LOGGER=ON
).
By default errors and warnings are logged to stderr and syslog, while notice and info message are only logged to syslog. Debug level message are not logged by default, but will be logged to syslog, if ENABLE_DEBUG=ON
is set in CMake.
The file sink behaves like syslog, if it has been enabled (see below).
If Elektra should display all log messages, then please follow the steps below.
in the file src/libs/elektra/log.c
. (Alternatively you may define this macro via CMake.)
src/include/kdblogger.h
. For example, if you want to see everything (including debug messages) on stderr, then change the lineto
If you want to only log messages below a specific directory prefix, then please follow the steps below.
in the file src/libs/elektra/log.c
.
, where src/postfix
contains all source files with logging statements that Elektra should log. For example, if you want to log everything from the yamlcpp
plugin, then use the following code.
. To log messages from multiple source you can use the operator &&
to chain multiple calls to strncmp
. For example, to log messages from the directoryvalue
and yamlcpp
plugin use the code:
The logging framework has 3 sinks: stderr, syslog and file.
The first to are enabled by default, while file is disabled. To enable it uncomment the line
in src/libs/elektra/log.c
. The file that log messages are written to is defined in this line
cmake
with the switch -DENABLE_LOGGER=ON
There are four log levels (ERROR is reserved for aborts within ELEKTRA_ASSERT
):
ELEKTRA_LOG_WARNING
, something critical that should be shown to the user (e.g. API misuse), see ELEKTRA_LOG_LEVEL_WARNINGELEKTRA_LOG_NOTICE
, something important developers are likely interested in, see ELEKTRA_LOG_LEVEL_NOTICEELEKTRA_LOG
, standard level gives information what the code is doing without flooding the log, see ELEKTRA_LOG_LEVEL_INFOELEKTRA_LOG_DEBUG
, for less important logs, see ELEKTRA_LOG_LEVEL_DEBUG