mirror of
https://github.com/espressif/openthread.git
synced 2026-07-18 01:54:07 +00:00
Enable dynamic log level selection (#1492)
This commit adds support for the dynamic log level selection. Config option `OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL` can be used to enable/disable this feature (default setting is disabled). Note that the `OPENTHREAD_CONFIG_LOG_LEVEL` specifies the log level at compile/build time. The dynamic log level feature (if enabled) only allows decreasing log level from the compile time setting. This commit also adds `SPINEL_PROP_DEBUG_NCP_LOG_LEVEL` as a new spinel property to control the log level. The set/get handlers for this property along with its documentation are also added. This commit modifies some of the log related macros/methods so to harmonize them all to require an `otInstance` as their first argument.
This commit is contained in:
committed by
Jonathan Hui
parent
db0e2057ef
commit
0ad2cc0b5b
@@ -33,6 +33,12 @@
|
||||
|
||||
#define WPP_NAME "instance_api.tmh"
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_FILE
|
||||
#include OPENTHREAD_CONFIG_FILE
|
||||
#else
|
||||
#include <openthread-config.h>
|
||||
#endif
|
||||
|
||||
#include "openthread/instance.h"
|
||||
#include "openthread/platform/misc.h"
|
||||
#include "openthread/platform/settings.h"
|
||||
@@ -61,6 +67,9 @@ otInstance::otInstance(void) :
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
, mApplicationCoapServer(mIp6.mUdp, OT_DEFAULT_COAP_PORT)
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
|
||||
, mLogLevel(static_cast<otLogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL))
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
|
||||
{
|
||||
}
|
||||
|
||||
@@ -214,6 +223,35 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otLogLevel otGetDynamicLogLevel(otInstance *aInstance)
|
||||
{
|
||||
otLogLevel logLevel;
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
|
||||
logLevel = aInstance->mLogLevel;
|
||||
#else
|
||||
logLevel = static_cast<otLogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL);
|
||||
(void)aInstance;
|
||||
#endif
|
||||
|
||||
return logLevel;
|
||||
}
|
||||
|
||||
ThreadError otSetDynamicLogLevel(otInstance *aInstance, otLogLevel aLogLevel)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
|
||||
aInstance->mLogLevel = aLogLevel;
|
||||
#else
|
||||
error = kThreadError_NotCapable;
|
||||
(void)aInstance;
|
||||
(void)aLogLevel;
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user