mirror of
https://github.com/espressif/openthread.git
synced 2026-08-16 15:47:46 +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:
@@ -39,7 +39,7 @@
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/instance.hpp"
|
||||
#include "common/locator_getters.hpp"
|
||||
#include "common/logging.hpp"
|
||||
#include "common/log.hpp"
|
||||
#include "common/settings.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
#include "thread/mle_types.hpp"
|
||||
@@ -50,6 +50,8 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
RegisterLogModule("DuaManager");
|
||||
|
||||
DuaManager::DuaManager(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mRegistrationTask(aInstance, DuaManager::HandleRegistrationTask)
|
||||
@@ -156,11 +158,11 @@ Error DuaManager::GenerateDomainUnicastAddressIid(void)
|
||||
IgnoreError(Store());
|
||||
}
|
||||
|
||||
otLogInfoDua("Generated DUA: %s", mDomainUnicastAddress.GetAddress().ToString().AsCString());
|
||||
LogInfo("Generated DUA: %s", mDomainUnicastAddress.GetAddress().ToString().AsCString());
|
||||
}
|
||||
else
|
||||
{
|
||||
otLogWarnDua("Generate DUA: %s", ErrorToString(error));
|
||||
LogWarn("Generate DUA: %s", ErrorToString(error));
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -174,7 +176,7 @@ Error DuaManager::SetFixedDuaInterfaceIdentifier(const Ip6::InterfaceIdentifier
|
||||
VerifyOrExit(mFixedDuaInterfaceIdentifier.IsUnspecified() || mFixedDuaInterfaceIdentifier != aIid);
|
||||
|
||||
mFixedDuaInterfaceIdentifier = aIid;
|
||||
otLogInfoDua("Set DUA IID: %s", mFixedDuaInterfaceIdentifier.ToString().AsCString());
|
||||
LogInfo("Set DUA IID: %s", mFixedDuaInterfaceIdentifier.ToString().AsCString());
|
||||
|
||||
if (Get<ThreadNetif>().HasUnicastAddress(GetDomainUnicastAddress()))
|
||||
{
|
||||
@@ -203,7 +205,7 @@ void DuaManager::ClearFixedDuaInterfaceIdentifier(void)
|
||||
}
|
||||
}
|
||||
|
||||
otLogInfoDua("Cleared DUA IID: %s", mFixedDuaInterfaceIdentifier.ToString().AsCString());
|
||||
LogInfo("Cleared DUA IID: %s", mFixedDuaInterfaceIdentifier.ToString().AsCString());
|
||||
mFixedDuaInterfaceIdentifier.Clear();
|
||||
|
||||
exit:
|
||||
@@ -254,7 +256,7 @@ void DuaManager::UpdateRegistrationDelay(uint8_t aDelay)
|
||||
{
|
||||
mDelay.mFields.mRegistrationDelay = aDelay;
|
||||
|
||||
otLogDebgDua("update regdelay %d", mDelay.mFields.mRegistrationDelay);
|
||||
LogDebg("update regdelay %d", mDelay.mFields.mRegistrationDelay);
|
||||
UpdateTimeTickerRegistration();
|
||||
}
|
||||
}
|
||||
@@ -284,7 +286,7 @@ void DuaManager::UpdateReregistrationDelay(void)
|
||||
{
|
||||
mDelay.mFields.mReregistrationDelay = delay;
|
||||
UpdateTimeTickerRegistration();
|
||||
otLogDebgDua("update reregdelay %d", mDelay.mFields.mReregistrationDelay);
|
||||
LogDebg("update reregdelay %d", mDelay.mFields.mReregistrationDelay);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -297,7 +299,7 @@ void DuaManager::UpdateCheckDelay(uint8_t aDelay)
|
||||
{
|
||||
mDelay.mFields.mCheckDelay = aDelay;
|
||||
|
||||
otLogDebgDua("update checkdelay %d", mDelay.mFields.mCheckDelay);
|
||||
LogDebg("update checkdelay %d", mDelay.mFields.mCheckDelay);
|
||||
UpdateTimeTickerRegistration();
|
||||
}
|
||||
}
|
||||
@@ -355,8 +357,8 @@ void DuaManager::HandleTimeTick(void)
|
||||
bool attempt = false;
|
||||
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
otLogDebgDua("regdelay %d, reregdelay %d, checkdelay %d", mDelay.mFields.mRegistrationDelay,
|
||||
mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
|
||||
LogDebg("regdelay %d, reregdelay %d, checkdelay %d", mDelay.mFields.mRegistrationDelay,
|
||||
mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
|
||||
|
||||
if ((mDuaState != kNotExist) &&
|
||||
(TimerMilli::GetNow() > (mLastRegistrationTime + TimeMilli::SecToMsec(Mle::kDuaDadPeriod))))
|
||||
@@ -369,7 +371,7 @@ void DuaManager::HandleTimeTick(void)
|
||||
attempt = true;
|
||||
}
|
||||
#else
|
||||
otLogDebgDua("reregdelay %d, checkdelay %d", mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
|
||||
LogDebg("reregdelay %d, checkdelay %d", mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
|
||||
#endif
|
||||
|
||||
if ((mDelay.mFields.mCheckDelay > 0) && (--mDelay.mFields.mCheckDelay == 0))
|
||||
@@ -532,7 +534,7 @@ void DuaManager::PerformNextRegistration(void)
|
||||
Get<DataPollSender>().SendFastPolls();
|
||||
}
|
||||
|
||||
otLogInfoDua("Sent DUA.req for DUA %s", dua.ToString().AsCString());
|
||||
LogInfo("Sent DUA.req for DUA %s", dua.ToString().AsCString());
|
||||
|
||||
exit:
|
||||
if (error == kErrorNoBufs)
|
||||
@@ -540,7 +542,7 @@ exit:
|
||||
UpdateCheckDelay(Mle::kNoBufDelay);
|
||||
}
|
||||
|
||||
otLogInfoDua("PerformNextRegistration: %s", ErrorToString(error));
|
||||
LogInfo("PerformNextRegistration: %s", ErrorToString(error));
|
||||
FreeMessageOnError(message, error);
|
||||
}
|
||||
|
||||
@@ -583,7 +585,7 @@ exit:
|
||||
mRegistrationTask.Post();
|
||||
}
|
||||
|
||||
otLogInfoDua("Received DUA.rsp: %s", ErrorToString(error));
|
||||
LogInfo("Received DUA.rsp: %s", ErrorToString(error));
|
||||
}
|
||||
|
||||
void DuaManager::HandleDuaNotification(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
||||
@@ -600,14 +602,14 @@ void DuaManager::HandleDuaNotification(Coap::Message &aMessage, const Ip6::Messa
|
||||
|
||||
if (aMessage.IsConfirmable() && Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo) == kErrorNone)
|
||||
{
|
||||
otLogInfoDua("Sent DUA.ntf acknowledgment");
|
||||
LogInfo("Sent DUA.ntf acknowledgment");
|
||||
}
|
||||
|
||||
error = ProcessDuaResponse(aMessage);
|
||||
|
||||
exit:
|
||||
OT_UNUSED_VARIABLE(error);
|
||||
otLogInfoDua("Received DUA.ntf: %d", ErrorToString(error));
|
||||
LogInfo("Received DUA.ntf: %d", ErrorToString(error));
|
||||
}
|
||||
|
||||
Error DuaManager::ProcessDuaResponse(Coap::Message &aMessage)
|
||||
@@ -741,7 +743,7 @@ void DuaManager::SendAddressNotification(Ip6::Address & aAddress,
|
||||
|
||||
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoDua("Sent ADDR_NTF for child %04x DUA %s", aChild.GetRloc16(), aAddress.ToString().AsCString());
|
||||
LogInfo("Sent ADDR_NTF for child %04x DUA %s", aChild.GetRloc16(), aAddress.ToString().AsCString());
|
||||
|
||||
exit:
|
||||
|
||||
@@ -750,8 +752,8 @@ exit:
|
||||
FreeMessage(message);
|
||||
|
||||
// TODO: (DUA) (P4) may enhance to guarantee the delivery of DUA.ntf
|
||||
otLogWarnDua("Sent ADDR_NTF for child %04x DUA %s Error %s", aChild.GetRloc16(),
|
||||
aAddress.ToString().AsCString(), ErrorToString(error));
|
||||
LogWarn("Sent ADDR_NTF for child %04x DUA %s Error %s", aChild.GetRloc16(), aAddress.ToString().AsCString(),
|
||||
ErrorToString(error));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user