[logging] add log level platform handler (#7545)

Adds a log level platform handler that allow platform code to handle
OT log level changes.
This commit is contained in:
Simon Lin
2022-04-12 12:36:00 -07:00
committed by GitHub
parent 1c1a583d78
commit 0c754bb09d
4 changed files with 33 additions and 2 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (201)
#define OPENTHREAD_API_VERSION (202)
/**
* @addtogroup api-instance
+13
View File
@@ -161,6 +161,19 @@ typedef enum otLogRegion
*/
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...);
/**
* This function handles OpenThread log level changes.
*
* This platform function is called whenever the OpenThread log level changes.
* This platform function is optional since an empty weak implementation has been provided.
*
* @note Only applicable when `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`.
*
* @param[in] aLogLevel The new OpenThread log level.
*
*/
void otPlatLogHandleLevelChanged(otLogLevel aLogLevel);
/**
* @}
*
+18
View File
@@ -294,4 +294,22 @@ void Instance::GetBufferInfo(BufferInfo &aInfo)
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
void Instance::SetLogLevel(LogLevel aLogLevel)
{
if (aLogLevel != sLogLevel)
{
sLogLevel = aLogLevel;
otPlatLogHandleLevelChanged(sLogLevel);
}
}
extern "C" OT_TOOL_WEAK void otPlatLogHandleLevelChanged(otLogLevel aLogLevel)
{
OT_UNUSED_VARIABLE(aLogLevel);
}
#endif
} // namespace ot
+1 -1
View File
@@ -207,7 +207,7 @@ public:
* @param[in] aLogLevel A log level.
*
*/
static void SetLogLevel(LogLevel aLogLevel) { sLogLevel = aLogLevel; }
static void SetLogLevel(LogLevel aLogLevel);
#endif
/**