![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
The irsol
library comes packed with a flexible logging and assertion framework designed to help you build robust applications with clear diagnostics and fail-safe conditions.
Both the logging and assertion subsystems must be initialized by the user at application startup before any logging or assertions are used:
initLogging()
configures logging sinks, file outputs, and runtime logging level.initAssertHandler()
sets up the assertion failure callback behavior.You can control the logging verbosity at runtime by passing the desired level to initLogging()
:
This determines which log messages are emitted during execution. In the above example, ony log levels higher than debug
are emitted (trace
logs are ignored).
SPDLOG_ACTIVE_LEVEL
)To optimize your binary and exclude logs below a certain level at compile time, define the macro (which needs to be set prior to importing <spdlog/spdlog>
):
This controls which logging macros (e.g., IRSOL_LOG_DEBUG, IRSOL_LOG_INFO) generate any code at all, reducing runtime overhead.
Of course, if a log-level is configured to be ignored at compile time, setting a runtime level lower than the compile time level will not have any effect.
By default, the compile-time logging level for building executables in Release and Debug mode are the following:
trace
. All log levels are considered at compile timeinfo
. Logs with a lower level are ignored at compilation timeThe system supports named loggers for modular logging scopes:
The logging system configures multiple sinks by default:
These sinks receive all logs (both from global and named loggers), so logs appear both in console and files simultaneously. Different sinks are configured to have a different runtime log level by default:
Compilation mode | Debug | Release |
---|---|---|
Console logger | trace | info |
File logger | trace | info |
You can disable all assertions globally at compile time by defining the macro:
When IRSOL_DISABLE_ASSERT
is defined: