mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[log] check log level before dumping packet to string (#7138)
`otDump` will currently always dump to string and use the log level to decide whether to print it. Since this function is in the key path of packet handling, this behavior reduces network throughput. This commit adds a log level check to fix the issue.
This commit is contained in:
@@ -297,6 +297,8 @@ void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const
|
||||
size_t idLen = strlen(aId) + kFixedStringPart;
|
||||
ot::String<kStringLineLength> string;
|
||||
|
||||
VerifyOrExit(otLoggingGetLevel() >= aLogLevel);
|
||||
|
||||
for (size_t i = 0; i < (kWidth - idLen) / 2; i++)
|
||||
{
|
||||
string.Append("=");
|
||||
@@ -325,6 +327,9 @@ void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const
|
||||
}
|
||||
|
||||
otLogDump(aLogLevel, aLogRegion, "%s", string.AsCString());
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
#else // OPENTHREAD_CONFIG_LOG_PKT_DUMP
|
||||
void otDump(otLogLevel, otLogRegion, const char *, const void *, const size_t)
|
||||
|
||||
Reference in New Issue
Block a user