Skip to content

Overhaul logging implementation

Enrico Gamberini requested to merge overhaul-logging into master

This MR overhauls Daqling's logging implementation. Instead of having a single logger instance that's shared in the whole code-base a root logger is created from which a core and module logger instance is cloned from. Any entries logged via core/module are level-filtered according to what is seperately configured before they are forwarded to root. All log entries made in a loaded module are logged via module; log entries made from anywhere else are logged via core. It is thus possible to configure your in-development module to log as debug, while not being spammed by debug log entries made in core of daqling.

By declaring an object-wide symbol daqling::utilities::Logger::m_logger in the daqling executable and each built module, the logging API can remain untouched: when, say, INFO() in FileDataLoggerModule expands the symbol lookup resolves to m_logger in libDaqlingModuleFileDataLogger.so. When logging in daqling or libDaqlingCore.so instead, the lookup resolved to the symbol in daqling instead. The symbol in each module must be decorated with __attribute__((visibility("hidden"))) so that it does not alias to the symbol in daqling.

libDaqlingCore.so does not contain a m_logger symbol; it is implicitly imported from daqling.

Both loggers are now initialized and configured at the start of main().

Edited by Enrico Gamberini

Merge request reports