mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 09:29:51 +00:00
[log] implement new logging model with module name support (#7385)
This commit implements new logging model in OpenThread. Each core module can specify its own module name using `RegisterLogModule()`. The registered log module name is then included in the all the log messages emitted from the specific file. This model replaces and enhances the log region model.
This commit is contained in:
@@ -38,10 +38,12 @@
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/debug.hpp"
|
||||
#include "common/locator_getters.hpp"
|
||||
#include "common/logging.hpp"
|
||||
#include "common/log.hpp"
|
||||
|
||||
namespace ot {
|
||||
|
||||
RegisterLogModule("Notifier");
|
||||
|
||||
Notifier::Notifier(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mTask(aInstance, Notifier::EmitEvents)
|
||||
@@ -214,7 +216,7 @@ exit:
|
||||
|
||||
// LCOV_EXCL_START
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_CORE == 1)
|
||||
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
|
||||
|
||||
void Notifier::LogEvents(Events aEvents) const
|
||||
{
|
||||
@@ -231,8 +233,8 @@ void Notifier::LogEvents(Events aEvents) const
|
||||
{
|
||||
if (string.GetLength() >= kFlagsStringLineLimit)
|
||||
{
|
||||
otLogInfoCore("Notifier: StateChanged (0x%08x) %s%s ...", aEvents.GetAsFlags(), didLog ? "... " : "[",
|
||||
string.AsCString());
|
||||
LogInfo("StateChanged (0x%08x) %s%s ...", aEvents.GetAsFlags(), didLog ? "... " : "[",
|
||||
string.AsCString());
|
||||
string.Clear();
|
||||
didLog = true;
|
||||
addSpace = false;
|
||||
@@ -246,8 +248,7 @@ void Notifier::LogEvents(Events aEvents) const
|
||||
}
|
||||
|
||||
exit:
|
||||
otLogInfoCore("Notifier: StateChanged (0x%08x) %s%s]", aEvents.GetAsFlags(), didLog ? "... " : "[",
|
||||
string.AsCString());
|
||||
LogInfo("StateChanged (0x%08x) %s%s]", aEvents.GetAsFlags(), didLog ? "... " : "[", string.AsCString());
|
||||
}
|
||||
|
||||
const char *Notifier::EventToString(Event aEvent) const
|
||||
@@ -302,7 +303,7 @@ const char *Notifier::EventToString(Event aEvent) const
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_CORE == 1)
|
||||
#else // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
|
||||
|
||||
void Notifier::LogEvents(Events) const
|
||||
{
|
||||
@@ -313,7 +314,7 @@ const char *Notifier::EventToString(Event) const
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_CORE == 1)
|
||||
#endif // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
|
||||
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user