Logging - Platform
This module includes the platform abstraction for the debug log service.
Summary
Enumerations |
|
|---|---|
otLogRegion{
|
enum Represents log regions. |
Typedefs |
|
|---|---|
otLogLevel
|
typedefint
Represents the log level. |
otLogRegion
|
typedefenum otLogRegion
Represents log regions. |
Functions |
|
|---|---|
otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
void
Outputs logs.
|
otPlatLogHandleLevelChanged(otLogLevel aLogLevel)
|
void
Handles OpenThread log level changes.
|
otPlatLogHandleLogLevelChanged(otInstance *aInstance, otLogLevel aLogLevel)
|
void
Handles OpenThread instance-specific log level changes.
|
otPlatLogOutput(otInstance *aInstance, otLogLevel aLogLevel, const char *aLogLine)
|
void
Outputs a log line.
|
Macros |
|
|---|---|
OT_LOG_LEVEL_CRIT 1
|
Log level Critical.
|
OT_LOG_LEVEL_DEBG 5
|
Log level Debug.
|
OT_LOG_LEVEL_INFO 4
|
Log level Informational.
|
OT_LOG_LEVEL_NONE 0
|
Log level None.
|
OT_LOG_LEVEL_NOTE 3
|
Log level Notice.
|
OT_LOG_LEVEL_WARN 2
|
Log level Warning.
|
Enumerations
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.
Typedefs
otLogLevel
int otLogLevel
Represents the log level.
otLogRegion
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.
Functions
otPlatLog
void otPlatLog( otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ... )
Outputs logs.
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.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
otPlatLogHandleLevelChanged
void otPlatLogHandleLevelChanged( otLogLevel aLogLevel )
Handles OpenThread log level changes.
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.
| Details | |||
|---|---|---|---|
| Parameters |
|
otPlatLogHandleLogLevelChanged
void otPlatLogHandleLogLevelChanged( otInstance *aInstance, otLogLevel aLogLevel )
Handles OpenThread instance-specific log level changes.
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.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
otPlatLogOutput
void otPlatLogOutput( otInstance *aInstance, otLogLevel aLogLevel, const char *aLogLine )
Outputs a 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.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
Macros
OT_LOG_LEVEL_CRIT
OT_LOG_LEVEL_CRIT 1
Log level Critical.
OT_LOG_LEVEL_DEBG
OT_LOG_LEVEL_DEBG 5
Log level Debug.
OT_LOG_LEVEL_INFO
OT_LOG_LEVEL_INFO 4
Log level Informational.
OT_LOG_LEVEL_NONE
OT_LOG_LEVEL_NONE 0
Log level None.
OT_LOG_LEVEL_NOTE
OT_LOG_LEVEL_NOTE 3
Log level Notice.
OT_LOG_LEVEL_WARN
OT_LOG_LEVEL_WARN 2
Log level Warning.
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.