mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 06:49:54 +00:00
[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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
* @param[in] aLogLevel A log level.
|
||||
*
|
||||
*/
|
||||
static void SetLogLevel(LogLevel aLogLevel) { sLogLevel = aLogLevel; }
|
||||
static void SetLogLevel(LogLevel aLogLevel);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user