mirror of
https://github.com/espressif/openthread.git
synced 2026-08-23 18:59:51 +00:00
[logging] refine NOTE and WARN logs (#7369)
This commit refines `NOTE` and `WARN` logs: - Certain `INFO` and `WARN` logs are changed to `INFO` since they are normal situations.
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 (194)
|
||||
#define OPENTHREAD_API_VERSION (195)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -344,8 +344,9 @@ otError otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address
|
||||
* @param[in] aAddress A pointer to an IP Address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully unsubscribed to the Network Interface Multicast Address.
|
||||
* @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address.
|
||||
* @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal address.
|
||||
* @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found.
|
||||
*
|
||||
*/
|
||||
otError otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ void Output::OutputFormatV(const char *aFormat, va_list aArguments)
|
||||
|
||||
if (lineEnd > mOutputString)
|
||||
{
|
||||
otLogCli(OT_LOG_LEVEL_NOTE, "Output: %s", mOutputString);
|
||||
otLogCli(OT_LOG_LEVEL_DEBG, "Output: %s", mOutputString);
|
||||
}
|
||||
|
||||
lineEnd++;
|
||||
@@ -320,7 +320,7 @@ void Output::OutputFormatV(const char *aFormat, va_list aArguments)
|
||||
|
||||
if (truncated)
|
||||
{
|
||||
otLogCli(OT_LOG_LEVEL_NOTE, "Output: %s ...", mOutputString);
|
||||
otLogCli(OT_LOG_LEVEL_DEBG, "Output: %s ...", mOutputString);
|
||||
mOutputLength = 0;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ void Output::LogInput(const Arg *aArgs)
|
||||
inputString.Append(isFirst ? "%s" : " %s", aArgs->GetCString());
|
||||
}
|
||||
|
||||
otLogCli(OT_LOG_LEVEL_NOTE, "Input: %s", inputString.AsCString());
|
||||
otLogCli(OT_LOG_LEVEL_DEBG, "Input: %s", inputString.AsCString());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ void NdProxyTable::Clear(void)
|
||||
mCallback(mCallbackContext, OT_BACKBONE_ROUTER_NDPROXY_CLEARED, nullptr);
|
||||
}
|
||||
|
||||
LogNote("NdProxyTable::Clear!");
|
||||
LogInfo("NdProxyTable::Clear!");
|
||||
}
|
||||
|
||||
Error NdProxyTable::Register(const Ip6::InterfaceIdentifier &aAddressIid,
|
||||
|
||||
@@ -164,7 +164,8 @@ exit:
|
||||
|
||||
Error RoutingManager::LoadOrGenerateRandomOmrPrefix(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Error error = kErrorNone;
|
||||
bool generated = false;
|
||||
|
||||
if (Get<Settings>().Read<Settings::OmrPrefix>(mLocalOmrPrefix) != kErrorNone || !IsValidOmrPrefix(mLocalOmrPrefix))
|
||||
{
|
||||
@@ -182,23 +183,27 @@ Error RoutingManager::LoadOrGenerateRandomOmrPrefix(void)
|
||||
|
||||
mLocalOmrPrefix.Set(randomOmrPrefix);
|
||||
IgnoreError(Get<Settings>().Save<Settings::OmrPrefix>(mLocalOmrPrefix));
|
||||
generated = true;
|
||||
}
|
||||
|
||||
OT_UNUSED_VARIABLE(generated);
|
||||
|
||||
LogNote("Local OMR prefix: %s (%s)", mLocalOmrPrefix.ToString().AsCString(), generated ? "generated" : "loaded");
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error RoutingManager::LoadOrGenerateRandomOnLinkPrefix(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Error error = kErrorNone;
|
||||
bool generated = false;
|
||||
|
||||
if (Get<Settings>().Read<Settings::OnLinkPrefix>(mLocalOnLinkPrefix) != kErrorNone ||
|
||||
!mLocalOnLinkPrefix.IsUniqueLocal())
|
||||
{
|
||||
Ip6::NetworkPrefix randomOnLinkPrefix;
|
||||
|
||||
LogNote("No valid on-link prefix found in settings, generating new one");
|
||||
|
||||
error = randomOnLinkPrefix.GenerateRandomUla();
|
||||
if (error != kErrorNone)
|
||||
{
|
||||
@@ -211,8 +216,14 @@ Error RoutingManager::LoadOrGenerateRandomOnLinkPrefix(void)
|
||||
mLocalOnLinkPrefix.Set(randomOnLinkPrefix);
|
||||
|
||||
IgnoreError(Get<Settings>().Save<Settings::OnLinkPrefix>(mLocalOnLinkPrefix));
|
||||
generated = true;
|
||||
}
|
||||
|
||||
OT_UNUSED_VARIABLE(generated);
|
||||
|
||||
LogNote("Local on-link prefix: %s (%s)", mLocalOnLinkPrefix.ToString().AsCString(),
|
||||
generated ? "generated" : "loaded");
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
@@ -509,7 +520,7 @@ void RoutingManager::UnpublishLocalOmrPrefix(void)
|
||||
LogInfo("Unpublishing local OMR prefix %s from Thread network", mLocalOmrPrefix.ToString().AsCString());
|
||||
|
||||
exit:
|
||||
if (error != kErrorNone)
|
||||
if (error != kErrorNone && error != kErrorNotFound)
|
||||
{
|
||||
LogWarn("Failed to unpublish local OMR prefix %s from Thread network: %s",
|
||||
mLocalOmrPrefix.ToString().AsCString(), ErrorToString(error));
|
||||
|
||||
@@ -586,7 +586,7 @@ void BorderAgent::Start(void)
|
||||
Coap::CoapSecure &coaps = Get<Coap::CoapSecure>();
|
||||
Pskc pskc;
|
||||
|
||||
VerifyOrExit(mState == kStateStopped, error = kErrorAlready);
|
||||
VerifyOrExit(mState == kStateStopped, error = kErrorNone);
|
||||
|
||||
Get<KeyManager>().GetPskc(pskc);
|
||||
SuccessOrExit(error = coaps.Start(kBorderAgentUdpPort));
|
||||
|
||||
@@ -261,7 +261,7 @@ void DatasetManager::SendSet(void)
|
||||
VerifyOrExit(!mMgmtPending, error = kErrorBusy);
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsChild() || Get<Mle::MleRouter>().IsRouter(), error = kErrorInvalidState);
|
||||
|
||||
VerifyOrExit(Timestamp::Compare(GetTimestamp(), mLocal.GetTimestamp()) < 0, error = kErrorInvalidState);
|
||||
VerifyOrExit(Timestamp::Compare(GetTimestamp(), mLocal.GetTimestamp()) < 0, error = kErrorAlready);
|
||||
|
||||
if (IsActiveDataset())
|
||||
{
|
||||
|
||||
@@ -360,7 +360,7 @@ exit:
|
||||
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
|
||||
void LogError(const char *aActionText, Error aError)
|
||||
{
|
||||
if (aError != kErrorNone)
|
||||
if (aError != kErrorNone && aError != kErrorAlready)
|
||||
{
|
||||
LogWarn("Failed to %s: %s", aActionText, ErrorToString(aError));
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ Error Netif::UnsubscribeExternalMulticast(const Address &aAddress)
|
||||
entry = mMulticastAddresses.FindMatching(aAddress, prev);
|
||||
VerifyOrExit(entry != nullptr, error = kErrorNotFound);
|
||||
|
||||
VerifyOrExit(IsMulticastAddressExternal(*entry), error = kErrorInvalidArgs);
|
||||
VerifyOrExit(IsMulticastAddressExternal(*entry), error = kErrorRejected);
|
||||
|
||||
mMulticastAddresses.PopAfter(prev);
|
||||
|
||||
@@ -556,7 +556,7 @@ Error Netif::RemoveExternalUnicastAddress(const Address &aAddress)
|
||||
entry = mUnicastAddresses.FindMatching(aAddress, prev);
|
||||
VerifyOrExit(entry != nullptr, error = kErrorNotFound);
|
||||
|
||||
VerifyOrExit(IsUnicastAddressExternal(*entry), error = kErrorInvalidArgs);
|
||||
VerifyOrExit(IsUnicastAddressExternal(*entry), error = kErrorRejected);
|
||||
|
||||
mUnicastAddresses.PopAfter(prev);
|
||||
|
||||
|
||||
@@ -561,7 +561,7 @@ public:
|
||||
* @param[in] aAddress A reference to the multicast address.
|
||||
*
|
||||
* @retval kErrorNone Successfully unsubscribed to the unicast address.
|
||||
* @retval kErrorInvalidArgs The address indicated by @p aAddress is an internal address.
|
||||
* @retval kErrorRejected The address indicated by @p aAddress is an internal address.
|
||||
* @retval kErrorNotFound The multicast address was not found.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1032,7 +1032,7 @@ void AddressResolver::LogCacheEntryChange(EntryChange aChange,
|
||||
static_assert(6 == kReasonEvictingForNewEntry, "kReasonEvictingForNewEntry value is incorrect");
|
||||
static_assert(7 == kReasonRemovingEid, "kReasonRemovingEid value is incorrect");
|
||||
|
||||
LogNote("Cache entry %s: %s, 0x%04x%s%s - %s", kChangeStrings[aChange], aEntry.GetTarget().ToString().AsCString(),
|
||||
LogInfo("Cache entry %s: %s, 0x%04x%s%s - %s", kChangeStrings[aChange], aEntry.GetTarget().ToString().AsCString(),
|
||||
aEntry.GetRloc16(), (aList == nullptr) ? "" : ", list:", ListToString(aList), kReasonStrings[aReason]);
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -3125,7 +3125,7 @@ void Mle::HandleDataResponse(const Message &aMessage, const Ip6::MessageInfo &aM
|
||||
|
||||
Log(kMessageReceive, kTypeDataResponse, aMessageInfo.GetPeerAddr());
|
||||
|
||||
VerifyOrExit(aNeighbor && aNeighbor->IsStateValid(), error = kErrorSecurity);
|
||||
VerifyOrExit(aNeighbor && aNeighbor->IsStateValid(), error = kErrorDrop);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
|
||||
if (Tlv::FindTlvValueOffset(aMessage, Tlv::kLinkMetricsReport, metricsReportValueOffset, length) == kErrorNone)
|
||||
@@ -4351,8 +4351,16 @@ void Mle::LogError(MessageAction aAction, MessageType aType, Error aError)
|
||||
{
|
||||
if (aError != kErrorNone)
|
||||
{
|
||||
LogWarn("Failed to %s %s%s: %s", aAction == kMessageSend ? "send" : "process", MessageTypeToString(aType),
|
||||
MessageTypeActionToSuffixString(aType, aAction), ErrorToString(aError));
|
||||
if (aAction == kMessageReceive && (aError == kErrorDrop || aError == kErrorNoRoute))
|
||||
{
|
||||
LogInfo("Failed to %s %s%s: %s", "process", MessageTypeToString(aType),
|
||||
MessageTypeActionToSuffixString(aType, aAction), ErrorToString(aError));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWarn("Failed to %s %s%s: %s", aAction == kMessageSend ? "send" : "process", MessageTypeToString(aType),
|
||||
MessageTypeActionToSuffixString(aType, aAction), ErrorToString(aError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1323,7 +1323,7 @@ Error MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Message
|
||||
if (mParent.GetRloc16() != sourceAddress)
|
||||
{
|
||||
IgnoreError(BecomeDetached());
|
||||
ExitNow(error = kErrorNoRoute);
|
||||
ExitNow(error = kErrorDetached);
|
||||
}
|
||||
|
||||
if (IsFullThreadDevice())
|
||||
|
||||
@@ -160,7 +160,7 @@ static inline void LogIfFail(const char *aText, otError aError)
|
||||
OT_UNUSED_VARIABLE(aText);
|
||||
OT_UNUSED_VARIABLE(aError);
|
||||
|
||||
if (aError != OT_ERROR_NONE)
|
||||
if (aError != OT_ERROR_NONE && aError != OT_ERROR_NO_ACK)
|
||||
{
|
||||
otLogWarnPlat("%s: %s", aText, otThreadErrorToString(aError));
|
||||
}
|
||||
|
||||
@@ -849,7 +849,7 @@ exit:
|
||||
{
|
||||
if (error == OT_ERROR_DROP)
|
||||
{
|
||||
otLogNotePlat("[netif] Message dropped by Thread", otThreadErrorToString(error));
|
||||
otLogInfoPlat("[netif] Message dropped by Thread", otThreadErrorToString(error));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -863,7 +863,7 @@ static void logAddrEvent(bool isAdd, const ot::Ip6::Address &aAddress, otError e
|
||||
OT_UNUSED_VARIABLE(aAddress);
|
||||
|
||||
if ((error == OT_ERROR_NONE) || ((isAdd) && (error == OT_ERROR_ALREADY || error == OT_ERROR_REJECTED)) ||
|
||||
((!isAdd) && (error == OT_ERROR_NOT_FOUND)))
|
||||
((!isAdd) && (error == OT_ERROR_NOT_FOUND || error == OT_ERROR_REJECTED)))
|
||||
{
|
||||
otLogInfoPlat("[netif] %s [%s] %s%s", isAdd ? "ADD" : "DEL", aAddress.IsMulticast() ? "M" : "U",
|
||||
aAddress.ToString().AsCString(),
|
||||
@@ -950,7 +950,7 @@ static void processNetifAddrEvent(otInstance *aInstance, struct nlmsghdr *aNetli
|
||||
}
|
||||
|
||||
logAddrEvent(/* isAdd */ false, addr, error);
|
||||
if (error == OT_ERROR_NOT_FOUND)
|
||||
if (error == OT_ERROR_NOT_FOUND || error == OT_ERROR_REJECTED)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -168,11 +168,11 @@ void TestNetifMulticastAddresses(void)
|
||||
VerifyMulticastAddressList(netif, &addresses[0], 8);
|
||||
|
||||
IgnoreError(address.FromString(kTestAddress1)); // same as netifAddress (internal)
|
||||
VerifyOrQuit(netif.UnsubscribeExternalMulticast(address) == kErrorInvalidArgs,
|
||||
VerifyOrQuit(netif.UnsubscribeExternalMulticast(address) == kErrorRejected,
|
||||
"UnsubscribeExternalMulticast() did not fail when address was not external");
|
||||
|
||||
IgnoreError(address.FromString(kRealmLocalAllMpl));
|
||||
VerifyOrQuit(netif.UnsubscribeExternalMulticast(address) == kErrorInvalidArgs,
|
||||
VerifyOrQuit(netif.UnsubscribeExternalMulticast(address) == kErrorRejected,
|
||||
"UnsubscribeExternalMulticast() did not fail when address was fixed address");
|
||||
|
||||
netif.UnsubscribeAllRoutersMulticast();
|
||||
|
||||
Reference in New Issue
Block a user