mirror of
https://github.com/espressif/openthread.git
synced 2026-08-16 15:47:46 +00:00
[logging] introduce Log{Level}OnError macros and update core (#12533)
This commit introduces a new set of logging macros, `LogCritOnError`, `LogWarnOnError`, `LogNoteOnError`, `LogInfoOnError`, and `LogDebgOnError`, to provide a consistent and streamlined way to log errors across the codebase. The new macros automatically prepend "Failed to " and append the error string (using `ErrorToString()`) to the log message, reducing boilerplate code and ensuring a uniform log format. These macros only emit a log if the provided `Error` is not `kErrorNone`. This change improves code readability and maintainability by consolidating error logging logic into the logging framework.
This commit is contained in:
@@ -1947,8 +1947,8 @@ Error Mle::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWarn("Error %s adding IPv6 address %s to child 0x%04x", ErrorToString(error),
|
||||
address.ToString().AsCString(), aChild.GetRloc16());
|
||||
LogWarnOnError(error, "add IPv6 address %s to child 0x%04x", address.ToString().AsCString(),
|
||||
aChild.GetRloc16());
|
||||
}
|
||||
|
||||
if (address.IsMulticast())
|
||||
|
||||
Reference in New Issue
Block a user