Logging - Platform#
This module includes the platform abstraction for the debug log service.
Enumerations#
Represents log regions.
Functions#
Outputs logs.
Outputs a log line.
Handles OpenThread log level changes.
Handles OpenThread instance-specific log level changes.
Macros#
Log level None.
Log level Critical.
Log level Warning.
Log level Notice.
Log level Informational.
Log level Debug.
Enumeration Documentation#
otLogRegion#
otLogRegion
Represents log regions.
The support for log region is removed and instead each core module can define its own name to appended to the logs. However, the otLogRegion enumeration is still defined as before to help with platforms which we may be using it in their otPlatLog() implementation. The OT core will always emit all logs with OT_LOG_REGION_CORE.
| Enumerator | |
|---|---|
| OT_LOG_REGION_API | OpenThread API. |
| OT_LOG_REGION_MLE | MLE. |
| OT_LOG_REGION_ARP | EID-to-RLOC mapping. |
| OT_LOG_REGION_NET_DATA | Network Data. |
| OT_LOG_REGION_ICMP | ICMPv6. |
| OT_LOG_REGION_IP6 | IPv6. |
| OT_LOG_REGION_TCP | TCP. |
| OT_LOG_REGION_MAC | IEEE 802.15.4 MAC. |
| OT_LOG_REGION_MEM | Memory. |
| OT_LOG_REGION_NCP | NCP. |
| OT_LOG_REGION_MESH_COP | Mesh Commissioning Protocol. |
| OT_LOG_REGION_NET_DIAG | Network Diagnostic. |
| OT_LOG_REGION_PLATFORM | Platform. |
| OT_LOG_REGION_COAP | CoAP. |
| OT_LOG_REGION_CLI | CLI. |
| OT_LOG_REGION_CORE | OpenThread Core. |
| OT_LOG_REGION_UTIL | Utility module. |
| OT_LOG_REGION_BBR | Backbone Router (available since Thread 1.2) |
| OT_LOG_REGION_MLR | Multicast Listener Registration (available since Thread 1.2) |
| OT_LOG_REGION_DUA | Domain Unicast Address (available since Thread 1.2) |
| OT_LOG_REGION_BR | Border Router. |
| OT_LOG_REGION_SRP | Service Registration Protocol (SRP) |
| OT_LOG_REGION_DNS | DNS. |
Typedef Documentation#
otLogRegion#
typedef enum otLogRegion otLogRegion
Represents log regions.
The support for log region is removed and instead each core module can define its own name to appended to the logs. However, the otLogRegion enumeration is still defined as before to help with platforms which we may be using it in their otPlatLog() implementation. The OT core will always emit all logs with OT_LOG_REGION_CORE.
Function Documentation#
otPlatLog#
void otPlatLog (otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ... )
Outputs logs.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otLogLevel | [in] | aLogLevel | The log level. |
| otLogRegion | [in] | aLogRegion | The log region. |
| const char * | [in] | aFormat | A pointer to the format string. |
| ... | [in] | Arguments for the format specification. |
This platform API is used to output logs when the configuration OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE is disabled. When the configuration is enabled, otPlatLogOutput() is used instead.
Note that the support for log region is removed. The OT core will always emit all logs with OT_LOG_REGION_CORE as aLogRegion.
otPlatLogOutput#
void otPlatLogOutput (otInstance * aInstance, otLogLevel aLogLevel, const char * aLogLine)
Outputs a log line.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | A pointer to the OpenThread instance. |
| otLogLevel | [in] | aLogLevel | The log level. |
| const char * | [in] | aLogLine | A pointer to the null-terminated string containing the log line. |
This platform API is an alternative to otPlatLog() and is used when the configuration OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE is enabled.
Unlike otPlatLog(), this API also provides a pointer to the OpenThread instance (otInstance*) from which the log is generated. This is particularly helpful in a multi-instance setup to distinguish logs from different instances. Additionally, it provides the log line as a fully formatted null-terminated string instead of a format string and variable arguments.
otPlatLogHandleLevelChanged#
void otPlatLogHandleLevelChanged (otLogLevel aLogLevel)
Handles OpenThread log level changes.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otLogLevel | [in] | aLogLevel | The new OpenThread log level. |
This platform function is optional. An empty weak implementation is provided by OpenThread core.
This platform function is called whenever the OpenThread log level changes:
In a single-instance configuration, this is called when the log level changes.
In a multi-instance configuration, this is called when the global log level changes.
Note
Only applicable when
OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1.
otPlatLogHandleLogLevelChanged#
void otPlatLogHandleLogLevelChanged (otInstance * aInstance, otLogLevel aLogLevel)
Handles OpenThread instance-specific log level changes.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | A pointer to the OpenThread instance. |
| otLogLevel | [in] | aLogLevel | The new OpenThread log level for the instance. |
This platform function is optional. An empty weak implementation is provided by OpenThread core.
This platform function is called whenever the instance-specific log level changes:
In a single-instance configuration, this is called along with
otPlatLogHandleLevelChanged().In a multi-instance configuration, if
OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLEis used, this is called when the instance-specific log level changes.