This page contains an overview of the logging infrastructure used by the C-SDK Libraries.
The C-SDK libraries utilize one of the following 4 logging macro interfaces, each with a different verbosity level:
LogError
for Error levelLogWarn
for Warning levelLogInfo
for Info levelLogDebug
for Debug levelTo enable logging within the libraries, your application should implement these macros through the library-specific config file (for example, the core_mqtt_config.h
file for MQTT library). The implementation of these macros can be provided as a mapping to the your platform-specific logging framework.
The logging infrastructure architecture follows a dependency inversion design principle of allowing your application to inject an implementation of logging interface macros through the library-specific config file (like core_mqtt_config.h
).
For reference example of a POSIX-specific logging implementation, refer to the demos/logging-stack folder from the root directory of the C-SDK repository.
The logging_stack.h file contains the definition of all the logging interface macros (LogError
, LogWarn
, LogInfo
, LogDebug
) that eventually map to the standard C function, printf
.
The file contains the following features:
LOG_INFO
verbosity configuration, only the LogError
, LogWarn
, LogInfo
macros are enabled but the LogDebug
macro is disabled.LOG_ERROR
verbosity configuration does not generate code for logging calls for the LogWarn
, LogInfo
, or LogDebug
macros, ONLY for LogError
macro. [<Logging-Level>] [<Library-Name>] [<File-Name>:<Line-Number>]
. Here is an example snippet of log messages from the MQTT Basic TLS demo: For an example of how the demo projects utilize the logging stack, refer to any core_mqtt_config.h
file in the MQTT demos folder of the C-SDK repository.