AWS IoT Device SDK C: Logging
Generate and print log messages
Return to main page ↑
Configuration

Configuration settings of the logging library.

Configuration settings are C pre-processor constants. They can be set with a #define in the config file (iot_config.h) or by using a compiler option such as -D in gcc. If a configuration setting is not defined, the library will use a "sensible" default value (unless otherwise noted). Because they are compile-time constants, a library must be rebuilt if a configuration setting is changed.

configpagemarker

LIBRARY_LOG_LEVEL

The log level for a source file.

Sets the log level for a single source file. A log message will only be printed if its level is less than this setting.

Both this constant and LIBRARY_LOG_NAME must be defined before including iot_logging_setup.h. See Setup and use for an example on how to use this setting.

Possible values: One of the Log levels.

Note
This value must be defined if iot_logging_setup.h is included. The library will not provide a default value for this setting.

LIBRARY_LOG_NAME

The library name printed in log messages.

Sets the library name for a single source file. By default, all log messages contain the library name. The library name may be disabled for a single log message by setting passing an IotLogConfig_t with hideLibraryName set to true.

Both this constant and LIBRARY_LOG_LEVEL must be defined before including iot_logging_setup.h. See Setup and use for an example on how to use this setting.

Possible values: Any string.

Note
This value must be defined if iot_logging_setup.h is included. The library will not provide a default value for this setting.

IotLogging_Puts

Logging library output function.

The logging library calls this function to print strings. Like the standard library's puts function, this function should write a newline after the string, as log messages may not end with a newline. This setting provided the flexibility to log over different channels. For example, if no stdout is available, this function may be set to log over other channels such as UART or a network.

Although this function is supposed to return an int, the logging library does not check its return value. Therefore, a function with no return type is also acceptable.

Possible values: Any function with the same parameter as the standard library's puts function. Since the logging library does not check the return value of this function, the return type may differ from puts.
Default value (if undefined): Standard library puts function.

Memory allocation

If IOT_STATIC_MEMORY_ONLY is 1, then the following functions must be re-implemented for the logging library.

Note that the logging library will silently discard logs if it fails to allocate memory for the message.