[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:
Abtin Keshavarzian
2022-02-17 15:50:45 -08:00
committed by GitHub
parent f759d163dc
commit 564982c818
146 changed files with 2170 additions and 4282 deletions
+1 -1
View File
@@ -228,7 +228,7 @@ LOCAL_SRC_FILES := \
src/core/common/heap_data.cpp \
src/core/common/heap_string.cpp \
src/core/common/instance.cpp \
src/core/common/logging.cpp \
src/core/common/log.cpp \
src/core/common/message.cpp \
src/core/common/notifier.cpp \
src/core/common/random_manager.cpp \
-1
View File
@@ -381,7 +381,6 @@ if(OT_FULL_LOGS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
endif()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1")
endif()
option(OT_OTNS "enable OTNS support")
+1 -1
View File
@@ -33,11 +33,11 @@
#include <openthread-system.h>
#include <openthread/cli.h>
#include <openthread/logging.h>
#include "cli/cli_config.h"
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/logging.hpp"
#include "utils/uart.h"
#if OPENTHREAD_POSIX
+1 -9
View File
@@ -150,21 +150,13 @@ pseudo_reset:
return 0;
}
/*
* Provide, if required an "otPlatLog()" function
*/
#if OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_APP
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
va_list ap;
va_start(ap, aFormat);
otCliPlatLogv(aLogLevel, aLogRegion, aFormat, ap);
va_end(ap);
}
void otPlatLogLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogLine)
{
otCliPlatLogLine(aLogLevel, aLogRegion, aLogLine);
}
#endif
+1 -1
View File
@@ -388,5 +388,5 @@ endif
COMMONCFLAGS += -DOPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${RCP_RESTORATION_MAX_COUNT}
ifeq ($(FULL_LOGS),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG -DOPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1 -DOPENTHREAD_CONFIG_LOG_PREPEND_REGION=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG -DOPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1
endif
+1 -1
View File
@@ -33,12 +33,12 @@
*/
#include <openthread/config.h>
#include <openthread/logging.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include <openthread/platform/radio.h>
#include "platform-cc2538.h"
#include "common/logging.hpp"
#include "utils/code_utils.h"
#define RFCORE_XREG_RFIRQM0 0x4008868C // RF interrupt masks
+1 -1
View File
@@ -47,11 +47,11 @@
timer_t sMicroTimer;
#endif // __linux__
#include <openthread/logging.h>
#include <openthread/platform/alarm-micro.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include "core/common/logging.hpp"
#include "lib/platform/exit_code.h"
#define MS_PER_S 1000
+1 -1
View File
@@ -37,9 +37,9 @@
#include <unistd.h>
#include <openthread/config.h>
#include <openthread/logging.h>
#include <openthread/platform/flash.h>
#include "core/common/logging.hpp"
#include "lib/platform/exit_code.h"
static int sFlashFd = -1;
+6 -21
View File
@@ -43,37 +43,22 @@
#include "utils/code_utils.h"
// Macro to append content to end of the log string.
#define LOG_PRINTF(...) \
charsWritten = snprintf(&logString[offset], sizeof(logString) - offset, __VA_ARGS__); \
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0); \
offset += (unsigned int)charsWritten; \
otEXPECT_ACTION(offset < sizeof(logString), logString[sizeof(logString) - 1] = 0)
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
char logString[512];
unsigned int offset;
int charsWritten;
va_list args;
char logString[512];
int offset;
va_list args;
offset = 0;
LOG_PRINTF("[%d] ", gNodeId);
offset = snprintf(logString, sizeof(logString), "[%d]", gNodeId);
va_start(args, aFormat);
charsWritten = vsnprintf(&logString[offset], sizeof(logString) - offset, aFormat, args);
vsnprintf(&logString[offset], sizeof(logString) - (uint16_t)offset, aFormat, args);
va_end(args);
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0);
exit:
syslog(LOG_CRIT, "%s", logString);
}
#endif // #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
#endif
+4 -2
View File
@@ -31,7 +31,9 @@
#include <openthread/platform/otns.h>
#include <openthread/platform/toolchain.h>
#include "common/logging.hpp"
#include "common/log.hpp"
using namespace ot;
/*
* Implementation note:
@@ -43,7 +45,7 @@
OT_TOOL_WEAK
void otPlatOtnsStatus(const char *aStatus)
{
otLogOtns("[OTNS] %s", aStatus);
LogAlways("[OTNS] %s", aStatus);
}
#endif // OPENTHREAD_CONFIG_OTNS_ENABLE
@@ -39,7 +39,8 @@
#include <stdlib.h>
#include <string.h>
#include "common/logging.hpp"
#include <openthread/logging.h>
#include "utils/code_utils.h"
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
-10
View File
@@ -146,16 +146,6 @@ void otCliAppendResult(otError aError);
*/
void otCliPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs);
/**
* Function to write the OpenThread Log to the CLI console.
*
* @param[in] aLogLevel The log level.
* @param[in] aLogRegion The log region.
* @param[in] aLogLine A pointer to the log line string.
*
*/
void otCliPlatLogLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogLine);
/**
* @}
*
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (192)
#define OPENTHREAD_API_VERSION (193)
/**
* @addtogroup api-instance
+138
View File
@@ -76,6 +76,144 @@ otLogLevel otLoggingGetLevel(void);
*/
otError otLoggingSetLevel(otLogLevel aLogLevel);
/**
* This function emits a log message at critical log level.
*
* This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
* level is below critical, this function does not emit any log message.
*
* @param[in] aFormat The format string.
* @param[in] ... Arguments for the format specification.
*
*/
void otLogCritPlat(const char *aFormat, ...);
/**
* This function emits a log message at warning log level.
*
* This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
* level is below warning, this function does not emit any log message.
*
* @param[in] aFormat The format string.
* @param[in] ... Arguments for the format specification.
*
*/
void otLogWarnPlat(const char *aFormat, ...);
/**
* This function emits a log message at note log level.
*
* This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
* level is below note, this function does not emit any log message.
*
* @param[in] aFormat The format string.
* @param[in] ... Arguments for the format specification.
*
*/
void otLogNotePlat(const char *aFormat, ...);
/**
* This function emits a log message at info log level.
*
* This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
* level is below info, this function does not emit any log message.
*
* @param[in] aFormat The format string.
* @param[in] ... Arguments for the format specification.
*
*/
void otLogInfoPlat(const char *aFormat, ...);
/**
* This function emits a log message at debug log level.
*
* This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
* level is below debug, this function does not emit any log message.
*
* @param[in] aFormat The format string.
* @param[in] ... Arguments for the format specification.
*
*/
void otLogDebgPlat(const char *aFormat, ...);
/**
* This function generates a memory dump at critical log level.
*
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
* critical this function does not emit any log message.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
void otDumpCritPlat(const char *aText, const void *aData, uint16_t aDataLength);
/**
* This function generates a memory dump at warning log level.
*
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
* warning this function does not emit any log message.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
void otDumpWarnPlat(const char *aText, const void *aData, uint16_t aDataLength);
/**
* This function generates a memory dump at note log level.
*
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
* note this function does not emit any log message.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
void otDumpNotePlat(const char *aText, const void *aData, uint16_t aDataLength);
/**
* This function generates a memory dump at info log level.
*
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
* info this function does not emit any log message.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
void otDumpInfoPlat(const char *aText, const void *aData, uint16_t aDataLength);
/**
* This function generates a memory dump at debug log level.
*
* If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
* debug this function does not emit any log message.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
void otDumpDebgPlat(const char *aText, const void *aData, uint16_t aDataLength);
/**
* This function emits a log message at a given log level.
*
* This function is intended for use by CLI only. If `OPENTHREAD_CONFIG_LOG_CLI` is not set or the current log
* level is below the given log level, this function does not emit any log message.
*
* @param[in] aLogLevel The log level.
* @param[in] aFormat The format string.
* @param[in] ... Arguments for the format specification.
*
*/
void otLogCli(otLogLevel aLogLevel, const char *aFormat, ...);
/**
* @}
*
+7 -13
View File
@@ -115,6 +115,10 @@ typedef int otLogLevel;
/**
* This enumeration represents log regions.
*
* The support for log region is removed and instead each core module can define its own name to appended to the logs.
* However, the `otLogRegion` enumeration is still defined as before to help with platforms which we may be using it
* in their `otPlatLog()` implementation. The OT core will always emit all logs with `OT_LOG_REGION_CORE`.
*
*/
typedef enum otLogRegion
{
@@ -146,6 +150,9 @@ typedef enum otLogRegion
/**
* This function outputs logs.
*
* Note that the support for log region is removed. The OT core will always emit all logs with `OT_LOG_REGION_CORE`
* as @p aLogRegion.
*
* @param[in] aLogLevel The log level.
* @param[in] aLogRegion The log region.
* @param[in] aFormat A pointer to the format string.
@@ -154,19 +161,6 @@ typedef enum otLogRegion
*/
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...);
/**
* This (optional) platform function outputs a prepared log line.
*
* Note that this function is optional and if not provided by platform layer, a default (weak) implementation is
* provided and used by OpenThread core as `otPlatLog(aLogLevel, aLogResion, "%s", aLogLine)`.
*
* @param[in] aLogLevel The log level.
* @param[in] aLogRegion The log region.
* @param[in] aLogLine A pointer to a log line string.
*
*/
void otPlatLogLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogLine);
/**
* @}
*
-16
View File
@@ -85,7 +85,6 @@
#include <openthread/trel.h>
#endif
#include "common/logging.hpp"
#include "common/new.hpp"
#include "common/string.hpp"
#include "mac/channel_mask.hpp"
@@ -5049,21 +5048,6 @@ exit:
return;
}
extern "C" void otCliPlatLogLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogLine)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
VerifyOrExit(Interpreter::IsInitialized());
Interpreter::GetInterpreter().SetEmittingCommandOutput(false);
Interpreter::GetInterpreter().OutputLine(aLogLine);
Interpreter::GetInterpreter().SetEmittingCommandOutput(true);
exit:
return;
}
} // namespace Cli
} // namespace ot
+1 -2
View File
@@ -46,6 +46,7 @@
#include <openthread/instance.h>
#include <openthread/ip6.h>
#include <openthread/link.h>
#include <openthread/logging.h>
#include <openthread/ping_sender.h>
#include <openthread/sntp.h>
#if OPENTHREAD_CONFIG_TCP_ENABLE && OPENTHREAD_CONFIG_CLI_TCP_ENABLE
@@ -89,7 +90,6 @@ namespace ot {
namespace Cli {
extern "C" void otCliPlatLogv(otLogLevel, otLogRegion, const char *, va_list);
extern "C" void otCliPlatLogLine(otLogLevel, otLogRegion, const char *);
extern "C" void otCliAppendResult(otError aError);
extern "C" void otCliOutputBytes(const uint8_t *aBytes, uint8_t aLength);
extern "C" void otCliOutputFormat(const char *aFmt, ...);
@@ -107,7 +107,6 @@ class Interpreter : public Output
friend class SrpClient;
#endif
friend void otCliPlatLogv(otLogLevel, otLogRegion, const char *, va_list);
friend void otCliPlatLogLine(otLogLevel, otLogRegion, const char *);
friend void otCliAppendResult(otError aError);
friend void otCliOutputBytes(const uint8_t *aBytes, uint8_t aLength);
friend void otCliOutputFormat(const char *aFmt, ...);
+4 -4
View File
@@ -40,8 +40,8 @@
#if OPENTHREAD_FTD || OPENTHREAD_MTD
#include <openthread/dns.h>
#endif
#include <openthread/logging.h>
#include "common/logging.hpp"
#include "common/string.hpp"
namespace ot {
@@ -279,7 +279,7 @@ void Output::OutputFormatV(const char *aFormat, va_list aArguments)
if (lineEnd > mOutputString)
{
otLogNoteCli("Output: %s", mOutputString);
otLogCli(OT_LOG_LEVEL_NOTE, "Output: %s", mOutputString);
}
lineEnd++;
@@ -320,7 +320,7 @@ void Output::OutputFormatV(const char *aFormat, va_list aArguments)
if (truncated)
{
otLogNoteCli("Output: %s ...", mOutputString);
otLogCli(OT_LOG_LEVEL_NOTE, "Output: %s ...", mOutputString);
mOutputLength = 0;
}
@@ -339,7 +339,7 @@ void Output::LogInput(const Arg *aArgs)
inputString.Append(isFirst ? "%s" : " %s", aArgs->GetCString());
}
otLogNoteCli("Input: %s", inputString.AsCString());
otLogCli(OT_LOG_LEVEL_NOTE, "Input: %s", inputString.AsCString());
}
#endif
+3 -3
View File
@@ -259,7 +259,6 @@ if (openthread_enable_core_config_args) {
if (openthread_config_full_logs) {
defines += [ "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG" ]
defines += [ "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1" ]
defines += [ "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1" ]
}
if (openthread_config_otns_enable) {
@@ -405,7 +404,8 @@ openthread_core_files = [
"common/linked_list.hpp",
"common/locator.hpp",
"common/locator_getters.hpp",
"common/logging.cpp",
"common/log.cpp",
"common/log.hpp",
"common/logging.hpp",
"common/message.cpp",
"common/message.hpp",
@@ -699,7 +699,7 @@ openthread_radio_sources = [
"common/binary_search.hpp",
"common/error.hpp",
"common/instance.cpp",
"common/logging.cpp",
"common/log.cpp",
"common/random_manager.cpp",
"common/string.cpp",
"common/tasklet.cpp",
+2 -2
View File
@@ -101,7 +101,7 @@ set(COMMON_SOURCES
common/heap_data.cpp
common/heap_string.cpp
common/instance.cpp
common/logging.cpp
common/log.cpp
common/message.cpp
common/notifier.cpp
common/random_manager.cpp
@@ -246,7 +246,7 @@ set(RADIO_COMMON_SOURCES
common/binary_search.cpp
common/error.cpp
common/instance.cpp
common/logging.cpp
common/log.cpp
common/random_manager.cpp
common/string.cpp
common/tasklet.cpp
+3 -2
View File
@@ -191,7 +191,7 @@ SOURCES_COMMON = \
common/heap_data.cpp \
common/heap_string.cpp \
common/instance.cpp \
common/logging.cpp \
common/log.cpp \
common/message.cpp \
common/notifier.cpp \
common/random_manager.cpp \
@@ -336,7 +336,7 @@ RADIO_SOURCES_COMMON = \
common/binary_search.cpp \
common/error.cpp \
common/instance.cpp \
common/logging.cpp \
common/log.cpp \
common/random_manager.cpp \
common/string.cpp \
common/tasklet.cpp \
@@ -442,6 +442,7 @@ HEADERS_COMMON = \
common/linked_list.hpp \
common/locator.hpp \
common/locator_getters.hpp \
common/log.hpp \
common/logging.hpp \
common/message.hpp \
common/new.hpp \
-2
View File
@@ -38,7 +38,6 @@
#include "common/as_core_type.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/new.hpp"
#include "radio/radio.hpp"
@@ -64,7 +63,6 @@ otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize)
Instance *instance;
instance = Instance::Init(aInstanceBuffer, aInstanceBufferSize);
otLogInfoApi("otInstance Initialized");
return instance;
}
-1
View File
@@ -37,7 +37,6 @@
#include "common/as_core_type.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "utils/slaac_address.hpp"
using namespace ot;
+156 -14
View File
@@ -33,19 +33,17 @@
#include "openthread-core-config.h"
#include <openthread/logging.h>
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/log.hpp"
using namespace ot;
otLogLevel otLoggingGetLevel(void)
{
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
return Instance::GetLogLevel();
#else
return static_cast<otLogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL);
#endif
return static_cast<otLogLevel>(Instance::GetLogLevel());
}
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
@@ -53,15 +51,159 @@ otError otLoggingSetLevel(otLogLevel aLogLevel)
{
Error error = kErrorNone;
if (aLogLevel <= OT_LOG_LEVEL_DEBG && aLogLevel >= OT_LOG_LEVEL_NONE)
{
Instance::SetLogLevel(aLogLevel);
}
else
{
error = kErrorInvalidArgs;
}
VerifyOrExit(aLogLevel <= kLogLevelDebg && aLogLevel >= kLogLevelNone, error = kErrorInvalidArgs);
Instance::SetLogLevel(static_cast<LogLevel>(aLogLevel));
exit:
return error;
}
#endif
static const char kPlatformModuleName[] = "Platform";
void otLogCritPlat(const char *aFormat, ...)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT) && OPENTHREAD_CONFIG_LOG_PLATFORM
va_list args;
va_start(args, aFormat);
Logger::LogVarArgs(kPlatformModuleName, kLogLevelCrit, aFormat, args);
va_end(args);
#else
OT_UNUSED_VARIABLE(aFormat);
OT_UNUSED_VARIABLE(kPlatformModuleName);
#endif
}
void otLogWarnPlat(const char *aFormat, ...)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN) && OPENTHREAD_CONFIG_LOG_PLATFORM
va_list args;
va_start(args, aFormat);
Logger::LogVarArgs(kPlatformModuleName, kLogLevelWarn, aFormat, args);
va_end(args);
#else
OT_UNUSED_VARIABLE(aFormat);
#endif
}
void otLogNotePlat(const char *aFormat, ...)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && OPENTHREAD_CONFIG_LOG_PLATFORM
va_list args;
va_start(args, aFormat);
Logger::LogVarArgs(kPlatformModuleName, kLogLevelNote, aFormat, args);
va_end(args);
#else
OT_UNUSED_VARIABLE(aFormat);
#endif
}
void otLogInfoPlat(const char *aFormat, ...)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && OPENTHREAD_CONFIG_LOG_PLATFORM
va_list args;
va_start(args, aFormat);
Logger::LogVarArgs(kPlatformModuleName, kLogLevelInfo, aFormat, args);
va_end(args);
#else
OT_UNUSED_VARIABLE(aFormat);
#endif
}
void otLogDebgPlat(const char *aFormat, ...)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG) && OPENTHREAD_CONFIG_LOG_PLATFORM
va_list args;
va_start(args, aFormat);
Logger::LogVarArgs(kPlatformModuleName, kLogLevelDebg, aFormat, args);
va_end(args);
#else
OT_UNUSED_VARIABLE(aFormat);
#endif
}
void otDumpCritPlat(const char *aText, const void *aData, uint16_t aDataLength)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT) && OPENTHREAD_CONFIG_LOG_PLATFORM && \
OPENTHREAD_CONFIG_LOG_PKT_DUMP
Logger::DumpInModule(kPlatformModuleName, kLogLevelCrit, aText, aData, aDataLength);
#else
OT_UNUSED_VARIABLE(aText);
OT_UNUSED_VARIABLE(aData);
OT_UNUSED_VARIABLE(aDataLength);
#endif
}
void otDumpWarnPlat(const char *aText, const void *aData, uint16_t aDataLength)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN) && OPENTHREAD_CONFIG_LOG_PLATFORM && \
OPENTHREAD_CONFIG_LOG_PKT_DUMP
Logger::DumpInModule(kPlatformModuleName, kLogLevelWarn, aText, aData, aDataLength);
#else
OT_UNUSED_VARIABLE(aText);
OT_UNUSED_VARIABLE(aData);
OT_UNUSED_VARIABLE(aDataLength);
#endif
}
void otDumpNotePlat(const char *aText, const void *aData, uint16_t aDataLength)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && OPENTHREAD_CONFIG_LOG_PLATFORM && \
OPENTHREAD_CONFIG_LOG_PKT_DUMP
Logger::DumpInModule(kPlatformModuleName, kLogLevelNote, aText, aData, aDataLength);
#else
OT_UNUSED_VARIABLE(aText);
OT_UNUSED_VARIABLE(aData);
OT_UNUSED_VARIABLE(aDataLength);
#endif
}
void otDumpInfoPlat(const char *aText, const void *aData, uint16_t aDataLength)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && OPENTHREAD_CONFIG_LOG_PLATFORM && \
OPENTHREAD_CONFIG_LOG_PKT_DUMP
Logger::DumpInModule(kPlatformModuleName, kLogLevelInfo, aText, aData, aDataLength);
#else
OT_UNUSED_VARIABLE(aText);
OT_UNUSED_VARIABLE(aData);
OT_UNUSED_VARIABLE(aDataLength);
#endif
}
void otDumpDebgPlat(const char *aText, const void *aData, uint16_t aDataLength)
{
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG) && OPENTHREAD_CONFIG_LOG_PLATFORM && \
OPENTHREAD_CONFIG_LOG_PKT_DUMP
Logger::DumpInModule(kPlatformModuleName, kLogLevelDebg, aText, aData, aDataLength);
#else
OT_UNUSED_VARIABLE(aText);
OT_UNUSED_VARIABLE(aData);
OT_UNUSED_VARIABLE(aDataLength);
#endif
}
void otLogCli(otLogLevel aLogLevel, const char *aFormat, ...)
{
#if OPENTHREAD_CONFIG_LOG_CLI
static const char kCliModuleName[] = "Cli";
va_list args;
OT_ASSERT(aLogLevel >= kLogLevelNone && aLogLevel <= kLogLevelDebg);
VerifyOrExit(aLogLevel >= kLogLevelNone && aLogLevel <= kLogLevelDebg);
va_start(args, aFormat);
Logger::LogVarArgs(kCliModuleName, static_cast<LogLevel>(aLogLevel), aFormat, args);
va_end(args);
exit:
#else
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aFormat);
#endif
return;
}
-1
View File
@@ -38,7 +38,6 @@
#include "common/as_core_type.hpp"
#include "common/code_utils.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
using namespace ot;
+5 -3
View File
@@ -36,11 +36,13 @@
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
namespace ot {
namespace BackboneRouter {
RegisterLogModule("Bbr");
Error BackboneTmfAgent::Start(void)
{
Error error = kErrorNone;
@@ -96,11 +98,11 @@ void BackboneTmfAgent::LogError(const char *aText, const Ip6::Address &aAddress,
if (aError == kErrorNone)
{
otLogInfoBbr("%s %s: %s", aText, aAddress.ToString().AsCString(), ErrorToString(aError));
LogInfo("%s %s: %s", aText, aAddress.ToString().AsCString(), ErrorToString(aError));
}
else
{
otLogWarnBbr("%s %s: %s", aText, aAddress.ToString().AsCString(), ErrorToString(aError));
LogWarn("%s %s: %s", aText, aAddress.ToString().AsCString(), ErrorToString(aError));
}
}
+10 -8
View File
@@ -37,11 +37,13 @@
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
namespace ot {
namespace BackboneRouter {
RegisterLogModule("BbrLeader");
Leader::Leader(Instance &aInstance)
: InstanceLocator(aInstance)
{
@@ -81,24 +83,24 @@ exit:
return error;
}
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void Leader::LogBackboneRouterPrimary(State aState, const BackboneRouterConfig &aConfig) const
{
OT_UNUSED_VARIABLE(aConfig);
otLogInfoBbr("PBBR state: %s", StateToString(aState));
LogInfo("PBBR state: %s", StateToString(aState));
if (aState != kStateRemoved && aState != kStateNone)
{
otLogInfoBbr("Rloc16: 0x%4X, seqno: %d, delay: %d, timeout %d", aConfig.mServer16, aConfig.mSequenceNumber,
aConfig.mReregistrationDelay, aConfig.mMlrTimeout);
LogInfo("Rloc16: 0x%4X, seqno: %d, delay: %d, timeout %d", aConfig.mServer16, aConfig.mSequenceNumber,
aConfig.mReregistrationDelay, aConfig.mMlrTimeout);
}
}
void Leader::LogDomainPrefix(DomainPrefixState aState, const Ip6::Prefix &aPrefix) const
{
otLogInfoBbr("Domain Prefix: %s, state: %s", aPrefix.ToString().AsCString(), DomainPrefixStateToString(aState));
LogInfo("Domain Prefix: %s, state: %s", aPrefix.ToString().AsCString(), DomainPrefixStateToString(aState));
}
const char *Leader::StateToString(State aState)
@@ -141,7 +143,7 @@ const char *Leader::DomainPrefixStateToString(DomainPrefixState aState)
return kPrefixStateStrings[aState];
}
#endif // (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
#endif // OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void Leader::Update(void)
{
@@ -204,7 +206,7 @@ void Leader::UpdateBackboneRouterPrimary(void)
if (config.mMlrTimeout != origMlrTimeout)
{
otLogNoteBbr("Leader MLR Timeout is normalized from %u to %u", origMlrTimeout, config.mMlrTimeout);
LogNote("Leader MLR Timeout is normalized from %u to %u", origMlrTimeout, config.mMlrTimeout);
}
}
+1 -1
View File
@@ -175,7 +175,7 @@ public:
private:
void UpdateBackboneRouterPrimary(void);
void UpdateDomainPrefixConfig(void);
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void LogBackboneRouterPrimary(State aState, const BackboneRouterConfig &aConfig) const;
void LogDomainPrefix(DomainPrefixState aState, const Ip6::Prefix &aPrefix) const;
static const char *StateToString(State aState);
+8 -6
View File
@@ -38,7 +38,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/random.hpp"
#include "thread/mle_types.hpp"
#include "thread/thread_netif.hpp"
@@ -47,6 +47,8 @@ namespace ot {
namespace BackboneRouter {
RegisterLogModule("BbrLocal");
Local::Local(Instance &aInstance)
: InstanceLocator(aInstance)
, mState(OT_BACKBONE_ROUTER_STATE_DISABLED)
@@ -458,17 +460,17 @@ void Local::AddDomainPrefixToNetworkData(void)
LogDomainPrefix("Add", error);
}
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void Local::LogDomainPrefix(const char *aAction, Error aError)
{
otLogInfoBbr("%s Domain Prefix: %s, %s", aAction, mDomainPrefixConfig.GetPrefix().ToString().AsCString(),
ErrorToString(aError));
LogInfo("%s Domain Prefix: %s, %s", aAction, mDomainPrefixConfig.GetPrefix().ToString().AsCString(),
ErrorToString(aError));
}
void Local::LogBackboneRouterService(const char *aAction, Error aError)
{
otLogInfoBbr("%s BBR Service: seqno (%d), delay (%ds), timeout (%ds), %s", aAction, mSequenceNumber,
mReregistrationDelay, mMlrTimeout, ErrorToString(aError));
LogInfo("%s BBR Service: seqno (%d), delay (%ds), timeout (%ds), %s", aAction, mSequenceNumber,
mReregistrationDelay, mMlrTimeout, ErrorToString(aError));
}
#endif
+1 -1
View File
@@ -274,7 +274,7 @@ private:
void AddDomainPrefixToNetworkData(void);
void RemoveDomainPrefixFromNetworkData(void);
void SequenceNumberIncrease(void);
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_BBR == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void LogBackboneRouterService(const char *aAction, Error aError);
void LogDomainPrefix(const char *aAction, Error aError);
#else
+25 -26
View File
@@ -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/random.hpp"
#include "thread/mle_types.hpp"
#include "thread/thread_netif.hpp"
@@ -50,6 +50,8 @@ namespace ot {
namespace BackboneRouter {
RegisterLogModule("BbrManager");
Manager::Manager(Instance &aInstance)
: InstanceLocator(aInstance)
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
@@ -108,11 +110,11 @@ void Manager::HandleNotifierEvents(Events aEvents)
if (error != kErrorNone)
{
otLogWarnBbr("Stop Backbone TMF agent: %s", ErrorToString(error));
LogWarn("Stop Backbone TMF agent: %s", ErrorToString(error));
}
else
{
otLogInfoBbr("Stop Backbone TMF agent: %s", ErrorToString(error));
LogInfo("Stop Backbone TMF agent: %s", ErrorToString(error));
}
}
else
@@ -226,7 +228,7 @@ void Manager::HandleMulticastListenerRegistration(const Coap::Message &aMessage,
if (timeout != origTimeout)
{
otLogNoteBbr("MLR.req: MLR timeout is normalized from %u to %u", origTimeout, timeout);
LogNote("MLR.req: MLR timeout is normalized from %u to %u", origTimeout, timeout);
}
}
}
@@ -328,7 +330,7 @@ void Manager::SendMulticastListenerRegistrationResponse(const Coap::Message &
exit:
FreeMessageOnError(message, error);
otLogInfoBbr("Sent MLR.rsp (status=%d): %s", aStatus, ErrorToString(error));
LogInfo("Sent MLR.rsp (status=%d): %s", aStatus, ErrorToString(error));
}
void Manager::SendBackboneMulticastListenerRegistration(const Ip6::Address *aAddresses,
@@ -365,7 +367,7 @@ void Manager::SendBackboneMulticastListenerRegistration(const Ip6::Address *aAdd
exit:
FreeMessageOnError(message, error);
otLogInfoBbr("Sent BMLR.ntf: %s", ErrorToString(error));
LogInfo("Sent BMLR.ntf: %s", ErrorToString(error));
}
#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
@@ -430,7 +432,7 @@ void Manager::HandleDuaRegistration(const Coap::Message &aMessage, const Ip6::Me
}
exit:
otLogInfoBbr("Received DUA.req on %s: %s", (isPrimary ? "PBBR" : "SBBR"), ErrorToString(error));
LogInfo("Received DUA.req on %s: %s", (isPrimary ? "PBBR" : "SBBR"), ErrorToString(error));
if (error == kErrorNone)
{
@@ -467,8 +469,7 @@ void Manager::SendDuaRegistrationResponse(const Coap::Message & aMessage,
exit:
FreeMessageOnError(message, error);
otLogInfoBbr("Sent DUA.rsp for DUA %s, status %d %s", aTarget.ToString().AsCString(), aStatus,
ErrorToString(error));
LogInfo("Sent DUA.rsp for DUA %s, status %d %s", aTarget.ToString().AsCString(), aStatus, ErrorToString(error));
}
#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE
@@ -555,8 +556,7 @@ Error Manager::SendBackboneQuery(const Ip6::Address &aDua, uint16_t aRloc16)
error = mBackboneTmfAgent.SendMessage(*message, messageInfo);
exit:
otLogInfoBbr("SendBackboneQuery for %s (rloc16=%04x): %s", aDua.ToString().AsCString(), aRloc16,
ErrorToString(error));
LogInfo("SendBackboneQuery for %s (rloc16=%04x): %s", aDua.ToString().AsCString(), aRloc16, ErrorToString(error));
FreeMessageOnError(message, error);
return error;
}
@@ -583,8 +583,8 @@ void Manager::HandleBackboneQuery(const Coap::Message &aMessage, const Ip6::Mess
error = Tlv::Find<ThreadRloc16Tlv>(aMessage, rloc16);
VerifyOrExit(error == kErrorNone || error == kErrorNotFound);
otLogInfoBbr("Received BB.qry from %s for %s (rloc16=%04x)", aMessageInfo.GetPeerAddr().ToString().AsCString(),
dua.ToString().AsCString(), rloc16);
LogInfo("Received BB.qry from %s for %s (rloc16=%04x)", aMessageInfo.GetPeerAddr().ToString().AsCString(),
dua.ToString().AsCString(), rloc16);
ndProxy = mNdProxyTable.ResolveDua(dua);
VerifyOrExit(ndProxy != nullptr && !ndProxy->GetDadFlag(), error = kErrorNotFound);
@@ -592,7 +592,7 @@ void Manager::HandleBackboneQuery(const Coap::Message &aMessage, const Ip6::Mess
error = SendBackboneAnswer(aMessageInfo, dua, rloc16, *ndProxy);
exit:
otLogInfoBbr("HandleBackboneQuery: %s", ErrorToString(error));
LogInfo("HandleBackboneQuery: %s", ErrorToString(error));
}
void Manager::HandleBackboneAnswer(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
@@ -643,7 +643,7 @@ void Manager::HandleBackboneAnswer(const Coap::Message &aMessage, const Ip6::Mes
SuccessOrExit(error = mBackboneTmfAgent.SendEmptyAck(aMessage, aMessageInfo));
exit:
otLogInfoBbr("HandleBackboneAnswer: %s", ErrorToString(error));
LogInfo("HandleBackboneAnswer: %s", ErrorToString(error));
}
Error Manager::SendProactiveBackboneNotification(const Ip6::Address & aDua,
@@ -706,8 +706,8 @@ Error Manager::SendBackboneAnswer(const Ip6::Address & aDstAddr,
error = mBackboneTmfAgent.SendMessage(*message, messageInfo);
exit:
otLogInfoBbr("Send %s for %s (rloc16=%04x): %s", proactive ? "PRO_BB.ntf" : "BB.ans", aDua.ToString().AsCString(),
aSrcRloc16, ErrorToString(error));
LogInfo("Send %s for %s (rloc16=%04x): %s", proactive ? "PRO_BB.ntf" : "BB.ans", aDua.ToString().AsCString(),
aSrcRloc16, ErrorToString(error));
FreeMessageOnError(message, error);
return error;
@@ -736,8 +736,8 @@ void Manager::HandleDadBackboneAnswer(const Ip6::Address &aDua, const Ip6::Inter
ot::BackboneRouter::NdProxyTable::NotifyDadComplete(*ndProxy, duplicate);
exit:
otLogInfoBbr("HandleDadBackboneAnswer: %s, target=%s, mliid=%s, duplicate=%s", ErrorToString(error),
aDua.ToString().AsCString(), aMeshLocalIid.ToString().AsCString(), duplicate ? "Y" : "N");
LogInfo("HandleDadBackboneAnswer: %s, target=%s, mliid=%s, duplicate=%s", ErrorToString(error),
aDua.ToString().AsCString(), aMeshLocalIid.ToString().AsCString(), duplicate ? "Y" : "N");
}
void Manager::HandleExtendedBackboneAnswer(const Ip6::Address & aDua,
@@ -750,9 +750,8 @@ void Manager::HandleExtendedBackboneAnswer(const Ip6::Address & aDua,
dest.SetToRoutingLocator(Get<Mle::MleRouter>().GetMeshLocalPrefix(), aSrcRloc16);
Get<AddressResolver>().SendAddressQueryResponse(aDua, aMeshLocalIid, &aTimeSinceLastTransaction, dest);
otLogInfoBbr("HandleExtendedBackboneAnswer: target=%s, mliid=%s, LTT=%lds, rloc16=%04x",
aDua.ToString().AsCString(), aMeshLocalIid.ToString().AsCString(), aTimeSinceLastTransaction,
aSrcRloc16);
LogInfo("HandleExtendedBackboneAnswer: target=%s, mliid=%s, LTT=%lds, rloc16=%04x", aDua.ToString().AsCString(),
aMeshLocalIid.ToString().AsCString(), aTimeSinceLastTransaction, aSrcRloc16);
}
void Manager::HandleProactiveBackboneNotification(const Ip6::Address & aDua,
@@ -788,8 +787,8 @@ void Manager::HandleProactiveBackboneNotification(const Ip6::Address &
}
exit:
otLogInfoBbr("HandleProactiveBackboneNotification: %s, target=%s, mliid=%s, LTT=%lds", ErrorToString(error),
aDua.ToString().AsCString(), aMeshLocalIid.ToString().AsCString(), aTimeSinceLastTransaction);
LogInfo("HandleProactiveBackboneNotification: %s, target=%s, mliid=%s, LTT=%lds", ErrorToString(error),
aDua.ToString().AsCString(), aMeshLocalIid.ToString().AsCString(), aTimeSinceLastTransaction);
}
#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE
@@ -799,11 +798,11 @@ void Manager::LogError(const char *aText, Error aError) const
if (aError == kErrorNone)
{
otLogInfoBbr("%s: %s", aText, ErrorToString(aError));
LogInfo("%s: %s", aText, ErrorToString(aError));
}
else
{
otLogWarnBbr("%s: %s", aText, ErrorToString(aError));
LogWarn("%s: %s", aText, ErrorToString(aError));
}
}
@@ -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/random.hpp"
#include "thread/mle_types.hpp"
#include "thread/thread_netif.hpp"
@@ -49,6 +49,8 @@ namespace ot {
namespace BackboneRouter {
RegisterLogModule("BbrMlt");
Error MulticastListenersTable::Add(const Ip6::Address &aAddress, Time aExpireTime)
{
Error error = kErrorNone;
@@ -155,8 +157,8 @@ void MulticastListenersTable::LogMulticastListenersTable(const char * aAc
OT_UNUSED_VARIABLE(aExpireTime);
OT_UNUSED_VARIABLE(aError);
otLogDebgBbr("MulticastListenersTable: %s %s expire %u: %s", aAction, aAddress.ToString().AsCString(),
aExpireTime.GetValue(), ErrorToString(aError));
LogDebg("%s %s expire %u: %s", aAction, aAddress.ToString().AsCString(), aExpireTime.GetValue(),
ErrorToString(aError));
}
void MulticastListenersTable::FixHeap(uint16_t aIndex)
+11 -9
View File
@@ -37,12 +37,14 @@
#include "common/array.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
namespace ot {
namespace BackboneRouter {
RegisterLogModule("BbrNdProxy");
void NdProxyTable::NdProxy::Init(const Ip6::InterfaceIdentifier &aAddressIid,
const Ip6::InterfaceIdentifier &aMeshLocalIid,
uint16_t aRloc16,
@@ -147,7 +149,7 @@ void NdProxyTable::Clear(void)
mCallback(mCallbackContext, OT_BACKBONE_ROUTER_NDPROXY_CLEARED, nullptr);
}
otLogNoteBbr("NdProxyTable::Clear!");
LogNote("NdProxyTable::Clear!");
}
Error NdProxyTable::Register(const Ip6::InterfaceIdentifier &aAddressIid,
@@ -186,8 +188,8 @@ Error NdProxyTable::Register(const Ip6::InterfaceIdentifier &aAddressIid,
mIsAnyDadInProcess = true;
exit:
otLogInfoBbr("NdProxyTable::Register %s MLIID %s RLOC16 %04x LTT %u => %s", aAddressIid.ToString().AsCString(),
aMeshLocalIid.ToString().AsCString(), aRloc16, timeSinceLastTransaction, ErrorToString(error));
LogInfo("NdProxyTable::Register %s MLIID %s RLOC16 %04x LTT %u => %s", aAddressIid.ToString().AsCString(),
aMeshLocalIid.ToString().AsCString(), aRloc16, timeSinceLastTransaction, ErrorToString(error));
return error;
}
@@ -204,8 +206,8 @@ NdProxyTable::NdProxy *NdProxyTable::FindByAddressIid(const Ip6::InterfaceIdenti
}
exit:
otLogDebgBbr("NdProxyTable::FindByAddressIid(%s) => %s", aAddressIid.ToString().AsCString(),
found ? found->mMeshLocalIid.ToString().AsCString() : "NOT_FOUND");
LogDebg("NdProxyTable::FindByAddressIid(%s) => %s", aAddressIid.ToString().AsCString(),
found ? found->mMeshLocalIid.ToString().AsCString() : "NOT_FOUND");
return found;
}
@@ -222,8 +224,8 @@ NdProxyTable::NdProxy *NdProxyTable::FindByMeshLocalIid(const Ip6::InterfaceIden
}
exit:
otLogDebgBbr("NdProxyTable::FindByMeshLocalIid(%s) => %s", aMeshLocalIid.ToString().AsCString(),
found ? found->mAddressIid.ToString().AsCString() : "NOT_FOUND");
LogDebg("NdProxyTable::FindByMeshLocalIid(%s) => %s", aMeshLocalIid.ToString().AsCString(),
found ? found->mAddressIid.ToString().AsCString() : "NOT_FOUND");
return found;
}
@@ -237,7 +239,7 @@ NdProxyTable::NdProxy *NdProxyTable::FindInvalid(void)
}
exit:
otLogDebgBbr("NdProxyTable::FindInvalid() => %s", found ? "OK" : "NOT_FOUND");
LogDebg("NdProxyTable::FindInvalid() => %s", found ? "OK" : "NOT_FOUND");
return found;
}
+74 -74
View File
@@ -44,7 +44,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "common/settings.hpp"
#include "net/ip6.hpp"
@@ -56,6 +56,8 @@ namespace ot {
namespace BorderRouter {
RegisterLogModule("BorderRouter");
RoutingManager::RoutingManager(Instance &aInstance)
: InstanceLocator(aInstance)
, mIsRunning(false)
@@ -168,13 +170,13 @@ Error RoutingManager::LoadOrGenerateRandomOmrPrefix(void)
{
Ip6::NetworkPrefix randomOmrPrefix;
otLogNoteBr("No valid OMR prefix found in settings, generating new one");
LogNote("No valid OMR prefix found in settings, generating new one");
// TODO: generate OMR prefix from the /48 BR ULA prefix
error = randomOmrPrefix.GenerateRandomUla();
if (error != kErrorNone)
{
otLogCritBr("Failed to generate random OMR prefix");
LogCrit("Failed to generate random OMR prefix");
ExitNow();
}
@@ -195,12 +197,12 @@ Error RoutingManager::LoadOrGenerateRandomOnLinkPrefix(void)
{
Ip6::NetworkPrefix randomOnLinkPrefix;
otLogNoteBr("No valid on-link prefix found in settings, generating new one");
LogNote("No valid on-link prefix found in settings, generating new one");
error = randomOnLinkPrefix.GenerateRandomUla();
if (error != kErrorNone)
{
otLogCritBr("Failed to generate random on-link prefix");
LogCrit("Failed to generate random on-link prefix");
ExitNow();
}
@@ -226,13 +228,13 @@ Error RoutingManager::LoadOrGenerateRandomNat64Prefix(void)
Ip6::NetworkPrefix randomNat64Prefix;
constexpr uint8_t nat64PrefixLength = 96;
otLogNoteBr("No valid NAT64 prefix found in settings, generating new one");
LogNote("No valid NAT64 prefix found in settings, generating new one");
// TODO: generate NAT64 prefix from the /48 BR ULA prefix
error = randomNat64Prefix.GenerateRandomUla();
if (error != kErrorNone)
{
otLogCritBr("Failed to generate random NAT64 prefix");
LogCrit("Failed to generate random NAT64 prefix");
ExitNow();
}
@@ -264,7 +266,7 @@ void RoutingManager::Start(void)
{
if (!mIsRunning)
{
otLogInfoBr("Border Routing manager started");
LogInfo("Border Routing manager started");
mIsRunning = true;
StartRouterSolicitationDelay();
@@ -315,7 +317,7 @@ void RoutingManager::Stop(void)
mRoutingPolicyTimer.Stop();
otLogInfoBr("Border Routing manager stopped");
LogInfo("Border Routing manager stopped");
mIsRunning = false;
@@ -352,7 +354,7 @@ void RoutingManager::RecvIcmp6Message(uint32_t aInfraIfIndex,
exit:
if (error != kErrorNone)
{
otLogDebgBr("Dropped ICMPv6 message: %s", ErrorToString(error));
LogDebg("Dropped ICMPv6 message: %s", ErrorToString(error));
}
}
@@ -364,8 +366,8 @@ Error RoutingManager::HandleInfraIfStateChanged(uint32_t aInfraIfIndex, bool aIs
VerifyOrExit(aInfraIfIndex == mInfraIfIndex, error = kErrorInvalidArgs);
VerifyOrExit(aIsRunning != mInfraIfIsRunning);
otLogInfoBr("Infra interface (%u) state changed: %sRUNNING -> %sRUNNING", aInfraIfIndex,
(mInfraIfIsRunning ? "" : "NOT "), (aIsRunning ? "" : "NOT "));
LogInfo("Infra interface (%u) state changed: %sRUNNING -> %sRUNNING", aInfraIfIndex,
(mInfraIfIsRunning ? "" : "NOT "), (aIsRunning ? "" : "NOT "));
mInfraIfIsRunning = aIsRunning;
EvaluateState();
@@ -420,7 +422,7 @@ void RoutingManager::EvaluateOmrPrefix(OmrPrefixArray &aNewOmrPrefixes)
if (aNewOmrPrefixes.PushBack(prefix) != kErrorNone)
{
otLogWarnBr("EvaluateOmrPrefix: Too many OMR prefixes, ignoring prefix %s", prefix.ToString().AsCString());
LogWarn("EvaluateOmrPrefix: Too many OMR prefixes, ignoring prefix %s", prefix.ToString().AsCString());
continue;
}
@@ -439,7 +441,7 @@ void RoutingManager::EvaluateOmrPrefix(OmrPrefixArray &aNewOmrPrefixes)
if (aNewOmrPrefixes.IsEmpty())
{
otLogInfoBr("EvaluateOmrPrefix: No valid OMR prefixes found in Thread network");
LogInfo("EvaluateOmrPrefix: No valid OMR prefixes found in Thread network");
if (PublishLocalOmrPrefix() == kErrorNone)
{
@@ -451,8 +453,8 @@ void RoutingManager::EvaluateOmrPrefix(OmrPrefixArray &aNewOmrPrefixes)
}
else if (publishedLocalOmrPrefix != nullptr && smallestOmrPrefix != publishedLocalOmrPrefix)
{
otLogInfoBr("EvaluateOmrPrefix: There is already a smaller OMR prefix %s in the Thread network",
smallestOmrPrefix->ToString().AsCString());
LogInfo("EvaluateOmrPrefix: There is already a smaller OMR prefix %s in the Thread network",
smallestOmrPrefix->ToString().AsCString());
UnpublishLocalOmrPrefix();
@@ -483,13 +485,13 @@ Error RoutingManager::PublishLocalOmrPrefix(void)
error = Get<NetworkData::Local>().AddOnMeshPrefix(omrPrefixConfig);
if (error != kErrorNone)
{
otLogWarnBr("Failed to publish local OMR prefix %s in Thread network: %s",
mLocalOmrPrefix.ToString().AsCString(), ErrorToString(error));
LogWarn("Failed to publish local OMR prefix %s in Thread network: %s", mLocalOmrPrefix.ToString().AsCString(),
ErrorToString(error));
}
else
{
Get<NetworkData::Notifier>().HandleServerDataUpdated();
otLogInfoBr("Publishing local OMR prefix %s in Thread network", mLocalOmrPrefix.ToString().AsCString());
LogInfo("Publishing local OMR prefix %s in Thread network", mLocalOmrPrefix.ToString().AsCString());
}
return error;
@@ -504,13 +506,13 @@ void RoutingManager::UnpublishLocalOmrPrefix(void)
SuccessOrExit(error = Get<NetworkData::Local>().RemoveOnMeshPrefix(mLocalOmrPrefix));
Get<NetworkData::Notifier>().HandleServerDataUpdated();
otLogInfoBr("Unpublishing local OMR prefix %s from Thread network", mLocalOmrPrefix.ToString().AsCString());
LogInfo("Unpublishing local OMR prefix %s from Thread network", mLocalOmrPrefix.ToString().AsCString());
exit:
if (error != kErrorNone)
{
otLogWarnBr("Failed to unpublish local OMR prefix %s from Thread network: %s",
mLocalOmrPrefix.ToString().AsCString(), ErrorToString(error));
LogWarn("Failed to unpublish local OMR prefix %s from Thread network: %s",
mLocalOmrPrefix.ToString().AsCString(), ErrorToString(error));
}
}
@@ -530,12 +532,12 @@ Error RoutingManager::AddExternalRoute(const Ip6::Prefix &aPrefix, RoutePreferen
error = Get<NetworkData::Local>().AddHasRoutePrefix(routeConfig);
if (error != kErrorNone)
{
otLogWarnBr("Failed to add external route %s: %s", aPrefix.ToString().AsCString(), ErrorToString(error));
LogWarn("Failed to add external route %s: %s", aPrefix.ToString().AsCString(), ErrorToString(error));
}
else
{
Get<NetworkData::Notifier>().HandleServerDataUpdated();
otLogInfoBr("Adding external route %s", aPrefix.ToString().AsCString());
LogInfo("Adding external route %s", aPrefix.ToString().AsCString());
}
return error;
@@ -550,12 +552,12 @@ void RoutingManager::RemoveExternalRoute(const Ip6::Prefix &aPrefix)
SuccessOrExit(error = Get<NetworkData::Local>().RemoveHasRoutePrefix(aPrefix));
Get<NetworkData::Notifier>().HandleServerDataUpdated();
otLogInfoBr("Removing external route %s", aPrefix.ToString().AsCString());
LogInfo("Removing external route %s", aPrefix.ToString().AsCString());
exit:
if (error != kErrorNone)
{
otLogWarnBr("Failed to remove external route %s: %s", aPrefix.ToString().AsCString(), ErrorToString(error));
LogWarn("Failed to remove external route %s: %s", aPrefix.ToString().AsCString(), ErrorToString(error));
}
}
@@ -604,8 +606,8 @@ const Ip6::Prefix *RoutingManager::EvaluateOnLinkPrefix(void)
}
else
{
otLogInfoBr("EvaluateOnLinkPrefix: There is already smaller on-link prefix %s on interface %u",
smallestOnLinkPrefix->ToString().AsCString(), mInfraIfIndex);
LogInfo("EvaluateOnLinkPrefix: There is already smaller on-link prefix %s on interface %u",
smallestOnLinkPrefix->ToString().AsCString(), mInfraIfIndex);
DeprecateOnLinkPrefix();
}
}
@@ -621,7 +623,7 @@ void RoutingManager::HandleOnLinkPrefixDeprecateTimer(Timer &aTimer)
void RoutingManager::HandleOnLinkPrefixDeprecateTimer(void)
{
otLogInfoBr("Local on-link prefix %s expired", mLocalOnLinkPrefix.ToString().AsCString());
LogInfo("Local on-link prefix %s expired", mLocalOnLinkPrefix.ToString().AsCString());
RemoveExternalRoute(mLocalOnLinkPrefix);
}
@@ -629,7 +631,7 @@ void RoutingManager::DeprecateOnLinkPrefix(void)
{
OT_ASSERT(mIsAdvertisingLocalOnLinkPrefix);
otLogInfoBr("Deprecate local on-link prefix %s", mLocalOnLinkPrefix.ToString().AsCString());
LogInfo("Deprecate local on-link prefix %s", mLocalOnLinkPrefix.ToString().AsCString());
mOnLinkPrefixDeprecateTimer.StartAt(mTimeAdvertisedOnLinkPrefix,
TimeMilli::SecToMsec(kDefaultOnLinkPrefixLifetime));
}
@@ -643,7 +645,7 @@ void RoutingManager::EvaluateNat64Prefix(void)
NetworkData::ExternalRouteConfig config;
Ip6::Prefix smallestNat64Prefix;
otLogInfoBr("Evaluating NAT64 prefix");
LogInfo("Evaluating NAT64 prefix");
smallestNat64Prefix.Clear();
while (Get<NetworkData::Leader>().GetNextExternalRoute(iterator, config) == kErrorNone)
@@ -661,8 +663,8 @@ void RoutingManager::EvaluateNat64Prefix(void)
if (smallestNat64Prefix.GetLength() == 0 || smallestNat64Prefix == mLocalNat64Prefix)
{
otLogInfoBr("No NAT64 prefix in Network Data is smaller than the local NAT64 prefix %s",
mLocalNat64Prefix.ToString().AsCString());
LogInfo("No NAT64 prefix in Network Data is smaller than the local NAT64 prefix %s",
mLocalNat64Prefix.ToString().AsCString());
// Advertise local NAT64 prefix.
if (!mIsAdvertisingLocalNat64Prefix &&
@@ -675,8 +677,8 @@ void RoutingManager::EvaluateNat64Prefix(void)
{
// Withdraw local NAT64 prefix if it's not the smallest one in Network Data.
// TODO: remove the prefix with lower preference after discovering upstream NAT64 prefix is supported
otLogNoteBr("Withdrawing local NAT64 prefix since a smaller one %s exists.",
smallestNat64Prefix.ToString().AsCString());
LogNote("Withdrawing local NAT64 prefix since a smaller one %s exists.",
smallestNat64Prefix.ToString().AsCString());
RemoveExternalRoute(mLocalNat64Prefix);
mIsAdvertisingLocalNat64Prefix = false;
@@ -695,7 +697,7 @@ void RoutingManager::EvaluateRoutingPolicy(void)
const Ip6::Prefix *newOnLinkPrefix = nullptr;
OmrPrefixArray newOmrPrefixes;
otLogInfoBr("Evaluating routing policy");
LogInfo("Evaluating routing policy");
// 0. Evaluate on-link & OMR prefixes.
newOnLinkPrefix = EvaluateOnLinkPrefix();
@@ -713,7 +715,7 @@ void RoutingManager::EvaluateRoutingPolicy(void)
// our local OMR prefix to the Thread network. We schedule the Router Advertisement
// timer to re-evaluate our routing policy in the future.
otLogWarnBr("No OMR prefix advertised! Start Router Advertisement timer for future evaluation");
LogWarn("No OMR prefix advertised! Start Router Advertisement timer for future evaluation");
}
// 2. Schedule Router Advertisement timer with random interval.
@@ -727,7 +729,7 @@ void RoutingManager::EvaluateRoutingPolicy(void)
nextSendDelay = kMaxInitRtrAdvInterval;
}
otLogInfoBr("Router advertisement scheduled in %u seconds", nextSendDelay);
LogInfo("Router advertisement scheduled in %u seconds", nextSendDelay);
StartRoutingPolicyEvaluationDelay(Time::SecToMsec(nextSendDelay));
}
@@ -745,7 +747,7 @@ void RoutingManager::StartRoutingPolicyEvaluationJitter(uint32_t aJitterMilli)
void RoutingManager::StartRoutingPolicyEvaluationDelay(uint32_t aDelayMilli)
{
otLogInfoBr("Start evaluating routing policy, scheduled in %u milliseconds", aDelayMilli);
LogInfo("Start evaluating routing policy, scheduled in %u milliseconds", aDelayMilli);
mRoutingPolicyTimer.FireAtIfEarlier(TimerMilli::GetNow() + aDelayMilli);
}
@@ -766,7 +768,7 @@ void RoutingManager::StartRouterSolicitationDelay(void)
static_assert(kMaxRtrSolicitationDelay > 0, "invalid maximum Router Solicitation delay");
randomDelay = Random::NonCrypto::GetUint32InRange(0, Time::SecToMsec(kMaxRtrSolicitationDelay));
otLogInfoBr("Start Router Solicitation, scheduled in %u milliseconds", randomDelay);
LogInfo("Start Router Solicitation, scheduled in %u milliseconds", randomDelay);
mTimeRouterSolicitStart = TimerMilli::GetNow();
mRouterSolicitTimer.Start(randomDelay);
@@ -823,12 +825,12 @@ void RoutingManager::SendRouterAdvertisement(const OmrPrefixArray &aNewOmrPrefix
if (!mIsAdvertisingLocalOnLinkPrefix)
{
otLogInfoBr("Start advertising new on-link prefix %s on interface %u",
aNewOnLinkPrefix->ToString().AsCString(), mInfraIfIndex);
LogInfo("Start advertising new on-link prefix %s on interface %u", aNewOnLinkPrefix->ToString().AsCString(),
mInfraIfIndex);
}
otLogInfoBr("Send on-link prefix %s in PIO (preferred lifetime = %u seconds, valid lifetime = %u seconds)",
aNewOnLinkPrefix->ToString().AsCString(), pio.GetPreferredLifetime(), pio.GetValidLifetime());
LogInfo("Send on-link prefix %s in PIO (preferred lifetime = %u seconds, valid lifetime = %u seconds)",
aNewOnLinkPrefix->ToString().AsCString(), pio.GetPreferredLifetime(), pio.GetValidLifetime());
mTimeAdvertisedOnLinkPrefix = TimerMilli::GetNow();
}
@@ -848,8 +850,8 @@ void RoutingManager::SendRouterAdvertisement(const OmrPrefixArray &aNewOmrPrefix
memcpy(buffer + bufferLength, &pio, pio.GetSize());
bufferLength += pio.GetSize();
otLogInfoBr("Send on-link prefix %s in PIO (preferred lifetime = %u seconds, valid lifetime = %u seconds)",
mLocalOnLinkPrefix.ToString().AsCString(), pio.GetPreferredLifetime(), pio.GetValidLifetime());
LogInfo("Send on-link prefix %s in PIO (preferred lifetime = %u seconds, valid lifetime = %u seconds)",
mLocalOnLinkPrefix.ToString().AsCString(), pio.GetPreferredLifetime(), pio.GetValidLifetime());
}
// Invalidate the advertised OMR prefixes if they are no longer in the new OMR prefix array.
@@ -868,8 +870,8 @@ void RoutingManager::SendRouterAdvertisement(const OmrPrefixArray &aNewOmrPrefix
memcpy(buffer + bufferLength, &rio, rio.GetSize());
bufferLength += rio.GetSize();
otLogInfoBr("Stop advertising OMR prefix %s on interface %u", advertisedOmrPrefix.ToString().AsCString(),
mInfraIfIndex);
LogInfo("Stop advertising OMR prefix %s on interface %u", advertisedOmrPrefix.ToString().AsCString(),
mInfraIfIndex);
}
}
@@ -884,8 +886,8 @@ void RoutingManager::SendRouterAdvertisement(const OmrPrefixArray &aNewOmrPrefix
memcpy(buffer + bufferLength, &rio, rio.GetSize());
bufferLength += rio.GetSize();
otLogInfoBr("Send OMR prefix %s in RIO (valid lifetime = %u seconds)", newOmrPrefix.ToString().AsCString(),
kDefaultOmrPrefixLifetime);
LogInfo("Send OMR prefix %s in RIO (valid lifetime = %u seconds)", newOmrPrefix.ToString().AsCString(),
kDefaultOmrPrefixLifetime);
}
// Send the message only when there are options.
@@ -901,12 +903,12 @@ void RoutingManager::SendRouterAdvertisement(const OmrPrefixArray &aNewOmrPrefix
if (error == kErrorNone)
{
otLogInfoBr("Sent Router Advertisement on interface %u", mInfraIfIndex);
otDumpDebgBr("[BR-CERT] direction=send | type=RA |", buffer, bufferLength);
LogInfo("Sent Router Advertisement on interface %u", mInfraIfIndex);
DumpDebg("[BR-CERT] direction=send | type=RA |", buffer, bufferLength);
}
else
{
otLogWarnBr("Failed to send Router Advertisement on interface %u: %s", mInfraIfIndex, ErrorToString(error));
LogWarn("Failed to send Router Advertisement on interface %u: %s", mInfraIfIndex, ErrorToString(error));
}
}
}
@@ -941,7 +943,7 @@ void RoutingManager::HandleVicariousRouterSolicitTimer(Timer &aTimer)
void RoutingManager::HandleVicariousRouterSolicitTimer(void)
{
otLogInfoBr("Vicarious router solicitation time out");
LogInfo("Vicarious router solicitation time out");
for (const ExternalPrefix &prefix : mDiscoveredPrefixes)
{
@@ -961,7 +963,7 @@ void RoutingManager::HandleRouterSolicitTimer(Timer &aTimer)
void RoutingManager::HandleRouterSolicitTimer(void)
{
otLogInfoBr("Router solicitation times out");
LogInfo("Router solicitation times out");
if (mRouterSolicitCount < kMaxRtrSolicitations)
{
@@ -972,14 +974,14 @@ void RoutingManager::HandleRouterSolicitTimer(void)
if (error == kErrorNone)
{
otLogDebgBr("Successfully sent %uth Router Solicitation", mRouterSolicitCount);
LogDebg("Successfully sent %uth Router Solicitation", mRouterSolicitCount);
++mRouterSolicitCount;
nextSolicitationDelay =
(mRouterSolicitCount == kMaxRtrSolicitations) ? kMaxRtrSolicitationDelay : kRtrSolicitationInterval;
}
else
{
otLogCritBr("Failed to send %uth Router Solicitation: %s", mRouterSolicitCount, ErrorToString(error));
LogCrit("Failed to send %uth Router Solicitation: %s", mRouterSolicitCount, ErrorToString(error));
// It's unexpected that RS will fail and we will retry sending RS messages in 60 seconds.
// Notice that `mRouterSolicitCount` is not incremented for failed RS and thus we will
@@ -989,7 +991,7 @@ void RoutingManager::HandleRouterSolicitTimer(void)
mRouterSolicitCount = 0;
}
otLogDebgBr("Router solicitation timer scheduled in %u seconds", nextSolicitationDelay);
LogDebg("Router solicitation timer scheduled in %u seconds", nextSolicitationDelay);
mRouterSolicitTimer.Start(Time::SecToMsec(nextSolicitationDelay));
}
else
@@ -1033,7 +1035,7 @@ void RoutingManager::HandleDiscoveredPrefixStaleTimer(Timer &aTimer)
void RoutingManager::HandleDiscoveredPrefixStaleTimer(void)
{
otLogInfoBr("Stale On-Link or OMR Prefixes or RA messages are detected");
LogInfo("Stale On-Link or OMR Prefixes or RA messages are detected");
StartRouterSolicitationDelay();
}
@@ -1060,8 +1062,7 @@ void RoutingManager::HandleRouterSolicit(const Ip6::Address &aSrcAddress,
OT_UNUSED_VARIABLE(aBuffer);
OT_UNUSED_VARIABLE(aBufferLength);
otLogInfoBr("Received Router Solicitation from %s on interface %u", aSrcAddress.ToString().AsCString(),
mInfraIfIndex);
LogInfo("Received Router Solicitation from %s on interface %u", aSrcAddress.ToString().AsCString(), mInfraIfIndex);
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
if (!mVicariousRouterSolicitTimer.IsRunning())
@@ -1111,9 +1112,8 @@ void RoutingManager::HandleRouterAdvertisement(const Ip6::Address &aSrcAddress,
VerifyOrExit(aBufferLength >= sizeof(RouterAdvMessage));
otLogInfoBr("Received Router Advertisement from %s on interface %u", aSrcAddress.ToString().AsCString(),
mInfraIfIndex);
otDumpDebgBr("[BR-CERT] direction=recv | type=RA |", aBuffer, aBufferLength);
LogInfo("Received Router Advertisement from %s on interface %u", aSrcAddress.ToString().AsCString(), mInfraIfIndex);
DumpDebg("[BR-CERT] direction=recv | type=RA |", aBuffer, aBufferLength);
routerAdvMessage = reinterpret_cast<const RouterAdvMessage *>(aBuffer);
optionsBegin = aBuffer + sizeof(RouterAdvMessage);
@@ -1179,14 +1179,14 @@ bool RoutingManager::UpdateDiscoveredOnLinkPrefix(const RouterAdv::PrefixInfoOpt
if (!IsValidOnLinkPrefix(aPio))
{
otLogInfoBr("Ignore invalid on-link prefix in PIO: %s", prefix.ToString().AsCString());
LogInfo("Ignore invalid on-link prefix in PIO: %s", prefix.ToString().AsCString());
ExitNow();
}
VerifyOrExit(!mIsAdvertisingLocalOnLinkPrefix || prefix != mLocalOnLinkPrefix);
otLogInfoBr("Discovered on-link prefix (%s, %u seconds) from interface %u", prefix.ToString().AsCString(),
aPio.GetValidLifetime(), mInfraIfIndex);
LogInfo("Discovered on-link prefix (%s, %u seconds) from interface %u", prefix.ToString().AsCString(),
aPio.GetValidLifetime(), mInfraIfIndex);
onLinkPrefix.mIsOnLinkPrefix = true;
onLinkPrefix.mPrefix = prefix;
@@ -1218,7 +1218,7 @@ bool RoutingManager::UpdateDiscoveredOnLinkPrefix(const RouterAdv::PrefixInfoOpt
}
else
{
otLogWarnBr("Discovered too many prefixes, ignore new on-link prefix %s", prefix.ToString().AsCString());
LogWarn("Discovered too many prefixes, ignore new on-link prefix %s", prefix.ToString().AsCString());
ExitNow();
}
}
@@ -1271,7 +1271,7 @@ void RoutingManager::UpdateDiscoveredOmrPrefix(const RouterAdv::RouteInfoOption
if (!IsValidOmrPrefix(prefix))
{
otLogInfoBr("Ignore invalid OMR prefix in RIO: %s", prefix.ToString().AsCString());
LogInfo("Ignore invalid OMR prefix in RIO: %s", prefix.ToString().AsCString());
ExitNow();
}
@@ -1291,8 +1291,8 @@ void RoutingManager::UpdateDiscoveredOmrPrefix(const RouterAdv::RouteInfoOption
VerifyOrExit(!mAdvertisedOmrPrefixes.Contains(prefix));
VerifyOrExit(!NetworkDataContainsOmrPrefix(prefix));
otLogInfoBr("Discovered OMR prefix (%s, %u seconds) from interface %u", prefix.ToString().AsCString(),
aRio.GetRouteLifetime(), mInfraIfIndex);
LogInfo("Discovered OMR prefix (%s, %u seconds) from interface %u", prefix.ToString().AsCString(),
aRio.GetRouteLifetime(), mInfraIfIndex);
if (aRio.GetRouteLifetime() == 0)
{
@@ -1328,7 +1328,7 @@ void RoutingManager::UpdateDiscoveredOmrPrefix(const RouterAdv::RouteInfoOption
}
else
{
otLogWarnBr("Discovered too many prefixes, ignore new prefix %s", prefix.ToString().AsCString());
LogWarn("Discovered too many prefixes, ignore new prefix %s", prefix.ToString().AsCString());
ExitNow();
}
}
@@ -1493,14 +1493,14 @@ void RoutingManager::ResetDiscoveredPrefixStaleTimer(void)
{
if (mDiscoveredPrefixStaleTimer.IsRunning())
{
otLogDebgBr("Prefix stale timer stopped");
LogDebg("Prefix stale timer stopped");
}
mDiscoveredPrefixStaleTimer.Stop();
}
else
{
mDiscoveredPrefixStaleTimer.FireAt(nextStaleTime);
otLogDebgBr("Prefix stale timer scheduled in %lu ms", nextStaleTime - now);
LogDebg("Prefix stale timer scheduled in %lu ms", nextStaleTime - now);
}
}
+18 -16
View File
@@ -34,7 +34,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "net/ip6.hpp"
#include "net/udp6.hpp"
@@ -48,6 +48,8 @@
namespace ot {
namespace Coap {
RegisterLogModule("Coap");
CoapBase::CoapBase(Instance &aInstance, Sender aSender)
: InstanceLocator(aInstance)
, mMessageId(Random::NonCrypto::GetUint16())
@@ -677,8 +679,8 @@ Error CoapBase::SendNextBlock1Request(Message & aRequest,
DequeueMessage(aRequest);
otLogInfoCoap("Send Block1 Nr. %d, Size: %d bytes, More Blocks Flag: %d", request->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(request->GetBlockWiseBlockSize()), request->IsMoreBlocksFlagSet());
LogInfo("Send Block1 Nr. %d, Size: %d bytes, More Blocks Flag: %d", request->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(request->GetBlockWiseBlockSize()), request->IsMoreBlocksFlagSet());
SuccessOrExit(error = SendMessage(*request, aMessageInfo, TxParameters::GetDefault(),
aCoapMetadata.mResponseHandler, aCoapMetadata.mResponseContext,
@@ -719,8 +721,8 @@ Error CoapBase::SendNextBlock2Request(Message & aRequest,
bufLen, aMessage.IsMoreBlocksFlagSet(), aTotalLength));
// CoAP Block-Wise Transfer continues
otLogInfoCoap("Received Block2 Nr. %d , Size: %d bytes, More Blocks Flag: %d", aMessage.GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(aMessage.GetBlockWiseBlockSize()), aMessage.IsMoreBlocksFlagSet());
LogInfo("Received Block2 Nr. %d , Size: %d bytes, More Blocks Flag: %d", aMessage.GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(aMessage.GetBlockWiseBlockSize()), aMessage.IsMoreBlocksFlagSet());
// Conclude block-wise transfer if last block has been received
if (!aMessage.IsMoreBlocksFlagSet())
@@ -739,8 +741,8 @@ Error CoapBase::SendNextBlock2Request(Message & aRequest,
DequeueMessage(aRequest);
}
otLogInfoCoap("Request Block2 Nr. %d, Size: %d bytes", request->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(request->GetBlockWiseBlockSize()));
LogInfo("Request Block2 Nr. %d, Size: %d bytes", request->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(request->GetBlockWiseBlockSize()));
SuccessOrExit(error =
SendMessage(*request, aMessageInfo, TxParameters::GetDefault(), aCoapMetadata.mResponseHandler,
@@ -790,8 +792,8 @@ Error CoapBase::ProcessBlock1Request(Message & aMessage,
SuccessOrExit(error = CacheLastBlockResponse(response));
otLogInfoCoap("Acknowledge Block1 Nr. %d, Size: %d bytes", response->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(response->GetBlockWiseBlockSize()));
LogInfo("Acknowledge Block1 Nr. %d, Size: %d bytes", response->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(response->GetBlockWiseBlockSize()));
SuccessOrExit(error = SendMessage(*response, aMessageInfo));
@@ -827,8 +829,8 @@ Error CoapBase::ProcessBlock2Request(Message & aMessage,
SuccessOrExit(error = aMessage.ReadBlockOptionValues(kOptionBlock2));
otLogInfoCoap("Request for Block2 Nr. %d, Size: %d bytes received", aMessage.GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(aMessage.GetBlockWiseBlockSize()));
LogInfo("Request for Block2 Nr. %d, Size: %d bytes received", aMessage.GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(aMessage.GetBlockWiseBlockSize()));
if (aMessage.GetBlockWiseBlockNumber() == 0)
{
@@ -927,8 +929,8 @@ Error CoapBase::ProcessBlock2Request(Message & aMessage,
FreeLastBlockResponse();
}
otLogInfoCoap("Send Block2 Nr. %d, Size: %d bytes, More Blocks Flag %d", response->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(response->GetBlockWiseBlockSize()), response->IsMoreBlocksFlagSet());
LogInfo("Send Block2 Nr. %d, Size: %d bytes, More Blocks Flag %d", response->GetBlockWiseBlockNumber(),
otCoapBlockSizeFromExponent(response->GetBlockWiseBlockSize()), response->IsMoreBlocksFlagSet());
SuccessOrExit(error = SendMessage(*response, aMessageInfo));
@@ -954,7 +956,7 @@ exit:
if (error != kErrorNone)
{
otLogWarnCoap("Failed to send copy: %s", ErrorToString(error));
LogWarn("Failed to send copy: %s", ErrorToString(error));
FreeMessage(messageCopy);
}
}
@@ -1007,7 +1009,7 @@ void CoapBase::Receive(ot::Message &aMessage, const Ip6::MessageInfo &aMessageIn
if (message.ParseHeader() != kErrorNone)
{
otLogDebgCoap("Failed to parse CoAP header");
LogDebg("Failed to parse CoAP header");
if (!aMessageInfo.GetSockAddr().IsMulticast() && message.IsConfirmable())
{
@@ -1399,7 +1401,7 @@ exit:
if (error != kErrorNone)
{
otLogInfoCoap("Failed to process request: %s", ErrorToString(error));
LogInfo("Failed to process request: %s", ErrorToString(error));
if (error == kErrorNotFound && !aMessageInfo.GetSockAddr().IsMulticast())
{
+5 -3
View File
@@ -32,7 +32,7 @@
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/new.hpp"
#include "meshcop/dtls.hpp"
#include "thread/thread_netif.hpp"
@@ -45,6 +45,8 @@
namespace ot {
namespace Coap {
RegisterLogModule("CoapSecure");
CoapSecure::CoapSecure(Instance &aInstance, bool aLayerTwoSecurity)
: CoapBase(aInstance, &CoapSecure::Send)
, mDtls(aInstance, aLayerTwoSecurity)
@@ -221,12 +223,12 @@ void CoapSecure::HandleTransmit(void)
exit:
if (error != kErrorNone)
{
otLogNoteMeshCoP("CoapSecure Transmit: %s", ErrorToString(error));
LogNote("Transmit: %s", ErrorToString(error));
message->Free();
}
else
{
otLogDebgMeshCoP("CoapSecure Transmit: %s", ErrorToString(error));
LogDebg("Transmit: %s", ErrorToString(error));
}
}
+1 -2
View File
@@ -35,7 +35,6 @@
#include <openthread/platform/misc.h>
#include "common/logging.hpp"
#include "common/new.hpp"
#include "radio/trel_link.hpp"
#include "utils/heap.hpp"
@@ -59,7 +58,7 @@ bool Instance::sDnsNameCompressionEnabled = true;
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
otLogLevel Instance::sLogLevel = static_cast<otLogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL_INIT);
LogLevel Instance::sLogLevel = static_cast<LogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL_INIT);
#endif
Instance::Instance(void)
+5 -9
View File
@@ -40,7 +40,6 @@
#include <stdint.h>
#include <openthread/heap.h>
#include <openthread/platform/logging.h>
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
#include <openthread/platform/memory.h>
#endif
@@ -49,6 +48,7 @@
#include "common/as_core_type.hpp"
#include "common/error.hpp"
#include "common/extension.hpp"
#include "common/log.hpp"
#include "common/message.hpp"
#include "common/non_copyable.hpp"
#include "common/random_manager.hpp"
@@ -181,14 +181,14 @@ public:
* @returns The log level.
*
*/
static otLogLevel GetLogLevel(void)
static LogLevel GetLogLevel(void)
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
{
return sLogLevel;
}
#else
{
return static_cast<otLogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL);
return static_cast<LogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL);
}
#endif
@@ -199,11 +199,7 @@ public:
* @param[in] aLogLevel A log level.
*
*/
static void SetLogLevel(otLogLevel aLogLevel)
{
OT_ASSERT(aLogLevel <= OT_LOG_LEVEL_DEBG && aLogLevel >= OT_LOG_LEVEL_NONE);
sLogLevel = aLogLevel;
}
static void SetLogLevel(LogLevel aLogLevel) { sLogLevel = aLogLevel; }
#endif
/**
@@ -396,7 +392,7 @@ private:
#endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
static otLogLevel sLogLevel;
static LogLevel sLogLevel;
#endif
#if OPENTHREAD_ENABLE_VENDOR_EXTENSION
Extension::ExtensionBase &mExtension;
+262
View File
@@ -0,0 +1,262 @@
/*
* Copyright (c) 2017-2022, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the logging related functions.
*/
#include "log.hpp"
#include <ctype.h>
#include <openthread/platform/logging.h>
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/string.hpp"
/*
* Verify debug UART dependency.
*
* It is reasonable to only enable the debug UART and not enable logs to the DEBUG UART.
*/
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && (!OPENTHREAD_CONFIG_ENABLE_DEBUG_UART)
#error "OPENTHREAD_CONFIG_ENABLE_DEBUG_UART_LOG requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART"
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME && !OPENTHREAD_CONFIG_UPTIME_ENABLE
#error "OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME requires OPENTHREAD_CONFIG_UPTIME_ENABLE"
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME && OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#error "OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME is not supported under OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE"
#endif
namespace ot {
template <LogLevel kLogLevel> void Logger::LogAtLevel(const char *aModuleName, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
LogVarArgs(aModuleName, kLogLevel, aFormat, args);
va_end(args);
}
// Explicit instantiations
template void Logger::LogAtLevel<kLogLevelNone>(const char *aModuleName, const char *aFormat, ...);
template void Logger::LogAtLevel<kLogLevelCrit>(const char *aModuleName, const char *aFormat, ...);
template void Logger::LogAtLevel<kLogLevelWarn>(const char *aModuleName, const char *aFormat, ...);
template void Logger::LogAtLevel<kLogLevelNote>(const char *aModuleName, const char *aFormat, ...);
template void Logger::LogAtLevel<kLogLevelInfo>(const char *aModuleName, const char *aFormat, ...);
template void Logger::LogAtLevel<kLogLevelDebg>(const char *aModuleName, const char *aFormat, ...);
void Logger::LogInModule(const char *aModuleName, LogLevel aLogLevel, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
LogVarArgs(aModuleName, aLogLevel, aFormat, args);
va_end(args);
}
void Logger::LogVarArgs(const char *aModuleName, LogLevel aLogLevel, const char *aFormat, va_list aArgs)
{
static const char kModuleNamePadding[] = "--------------";
ot::String<OPENTHREAD_CONFIG_LOG_MAX_SIZE> logString;
static_assert(sizeof(kModuleNamePadding) == kMaxLogModuleNameLength + 1, "Padding string is not correct");
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
ot::Uptime::UptimeToString(ot::Instance::Get().Get<ot::Uptime>().GetUptime(), logString);
logString.Append(" ");
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
VerifyOrExit(Instance::GetLogLevel() >= aLogLevel);
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
{
static const char kLevelChars[] = {
'-', /* kLogLevelNone */
'C', /* kLogLevelCrit */
'W', /* kLogLevelWarn */
'N', /* kLogLevelNote */
'I', /* kLogLevelInfo */
'D', /* kLogLevelDebg */
};
logString.Append("[%c] ", kLevelChars[aLogLevel]);
}
#endif
logString.Append("%.*s%s: ", kMaxLogModuleNameLength, aModuleName,
&kModuleNamePadding[StringLength(aModuleName, kMaxLogModuleNameLength)]);
logString.AppendVarArgs(aFormat, aArgs);
logString.Append("%s", OPENTHREAD_CONFIG_LOG_SUFFIX);
otPlatLog(aLogLevel, OT_LOG_REGION_CORE, "%s", logString.AsCString());
ExitNow();
exit:
return;
}
#if OPENTHREAD_CONFIG_LOG_PKT_DUMP
template <LogLevel kLogLevel>
void Logger::DumpAtLevel(const char *aModuleName, const char *aText, const void *aData, uint16_t aDataLength)
{
DumpInModule(aModuleName, kLogLevel, aText, aData, aDataLength);
}
// Explicit instantiations
template void Logger::DumpAtLevel<kLogLevelNone>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
template void Logger::DumpAtLevel<kLogLevelCrit>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
template void Logger::DumpAtLevel<kLogLevelWarn>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
template void Logger::DumpAtLevel<kLogLevelNote>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
template void Logger::DumpAtLevel<kLogLevelInfo>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
template void Logger::DumpAtLevel<kLogLevelDebg>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
void Logger::DumpLine(const char *aModuleName, LogLevel aLogLevel, const uint8_t *aData, const uint16_t aDataLength)
{
ot::String<kStringLineLength> string;
string.Append("|");
for (uint8_t i = 0; i < kDumpBytesPerLine; i++)
{
if (i < aDataLength)
{
string.Append(" %02X", aData[i]);
}
else
{
string.Append(" ..");
}
if (!((i + 1) % 8))
{
string.Append(" |");
}
}
string.Append(" ");
for (uint8_t i = 0; i < kDumpBytesPerLine; i++)
{
char c = '.';
if (i < aDataLength)
{
char byteAsChar = static_cast<char>(0x7f & aData[i]);
if (isprint(byteAsChar))
{
c = byteAsChar;
}
}
string.Append("%c", c);
}
LogInModule(aModuleName, aLogLevel, "%s", string.AsCString());
}
void Logger::DumpInModule(const char *aModuleName,
LogLevel aLogLevel,
const char *aText,
const void *aData,
uint16_t aDataLength)
{
constexpr uint16_t kWidth = 72;
constexpr uint16_t kTextSuffixLen = sizeof("[ len=000]") - 1;
uint16_t txtLen = StringLength(aText, kWidth - kTextSuffixLen) + kTextSuffixLen;
ot::String<kStringLineLength> string;
VerifyOrExit(otLoggingGetLevel() >= aLogLevel);
for (uint16_t i = 0; i < static_cast<uint16_t>((kWidth - txtLen) / 2); i++)
{
string.Append("=");
}
string.Append("[%s len=%03u]", aText, aDataLength);
for (uint16_t i = 0; i < static_cast<uint16_t>(kWidth - txtLen - (kWidth - txtLen) / 2); i++)
{
string.Append("=");
}
LogInModule(aModuleName, aLogLevel, "%s", string.AsCString());
for (uint16_t i = 0; i < aDataLength; i += kDumpBytesPerLine)
{
DumpLine(aModuleName, aLogLevel, static_cast<const uint8_t *>(aData) + i,
OT_MIN((aDataLength - i), kDumpBytesPerLine));
}
string.Clear();
for (uint16_t i = 0; i < kWidth; i++)
{
string.Append("-");
}
LogInModule(aModuleName, aLogLevel, "%s", string.AsCString());
exit:
return;
}
#endif // OPENTHREAD_CONFIG_LOG_PKT_DUMP
} // namespace ot
+346
View File
@@ -0,0 +1,346 @@
/*
* Copyright (c) 2022, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes logging related definitions.
*/
#ifndef LOG_HPP_
#define LOG_HPP_
#include "openthread-core-config.h"
#include <openthread/logging.h>
#include <openthread/platform/logging.h>
#include <openthread/platform/toolchain.h>
namespace ot {
/**
* This enumeration represents the log level.
*
*/
enum LogLevel : uint8_t
{
kLogLevelNone = OT_LOG_LEVEL_NONE, ///< None (disable logs)
kLogLevelCrit = OT_LOG_LEVEL_CRIT, ///< Critical log level
kLogLevelWarn = OT_LOG_LEVEL_WARN, ///< Warning log level
kLogLevelNote = OT_LOG_LEVEL_NOTE, ///< Note log level
kLogLevelInfo = OT_LOG_LEVEL_INFO, ///< Info log level
kLogLevelDebg = OT_LOG_LEVEL_DEBG, ///< Debug log level
};
constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length
/**
* This macro registers log module name.
*
* This macro is used in a `cpp` file to register the log module name for that file before using any other logging
* functions or macros (e.g., `LogInfo()` or `DumpInfo()`, ...) in the file.
*
* @param[in] aName The log module name string (MUST be shorter than `kMaxLogModuleNameLength`).
*
*/
#define RegisterLogModule(aName) \
constexpr char kLogModuleName[] = aName; \
namespace { \
/* Defining this type to silence "unused constant" warning/error \
* for `kLogModuleName` under any log level config. \
*/ \
using DummyType = char[sizeof(kLogModuleName)]; \
} \
static_assert(sizeof(kLogModuleName) <= kMaxLogModuleNameLength + 1, "Log module name is too long")
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT
/**
* This macro emits a log message at critical log level.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogCrit(...) Logger::Log<kLogLevelCrit, kLogModuleName>(__VA_ARGS__)
#else
#define LogCrit(...)
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
/**
* This macro emits a log message at warning log level.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogWarn(...) Logger::Log<kLogLevelWarn, kLogModuleName>(__VA_ARGS__)
#else
#define LogWarn(...)
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
/**
* This macro emits a log message at note log level.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogNote(...) Logger::Log<kLogLevelNote, kLogModuleName>(__VA_ARGS__)
#else
#define LogNote(...)
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
/**
* This macro emits a log message at info log level.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogInfo(...) Logger::Log<kLogLevelInfo, kLogModuleName>(__VA_ARGS__)
#else
#define LogInfo(...)
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG
/**
* This macro emits a log message at debug log level.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogDebg(...) Logger::Log<kLogLevelDebg, kLogModuleName>(__VA_ARGS__)
#else
#define LogDebg(...)
#endif
/**
* This macro emits a log message at a given log level.
*
* @param[in] aLogLevel The log level to use.
* @param[in] ... Argument for the format specification.
*
*/
#define LogAt(aLogLevel, ...) Logger::LogInModule(kLogModuleName, aLogLevel, __VA_ARGS__)
/**
* This macro emits a log message independent of the configured log level.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogAlways(...) Logger::LogInModule("", kLogLevelNone, __VA_ARGS__)
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
/**
* This macro emit a log message for the certification test.
*
* @param[in] ... Arguments for the format specification.
*
*/
#define LogCert(...) LogAlways(__VA_ARGS__)
#else
#define LogCert(...)
#endif
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT) && OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump at log level critical.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpCrit(aText, aData, aDataLength) Logger::Dump<kLogLevelCrit, kLogModuleName>(aText, aData, aDataLength)
#else
#define DumpCrit(aText, aData, aDataLength)
#endif
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN) && OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump at log level warning.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpWarn(aText, aData, aDataLength) Logger::Dump<kLogLevelWarn, kLogModuleName>(aText, aData, aDataLength)
#else
#define DumpWarn(aText, aData, aDataLength)
#endif
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump at log level note.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpNote(aText, aData, aDataLength) Logger::Dump<kLogLevelNote, kLogModuleName>(aText, aData, aDataLength)
#else
#define DumpNote(aText, aData, aDataLength)
#endif
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump at log level info.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpInfo(aText, aData, aDataLength) Logger::Dump<kLogLevelInfo, kLogModuleName>(aText, aData, aDataLength)
#else
#define DumpInfo(aText, aData, aDataLength)
#endif
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG) && OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump at log level debug.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpDebg(aText, aData, aDataLength) Logger::Dump<kLogLevelDebg, kLogModuleName>(aText, aData, aDataLength)
#else
#define DumpDebg(aText, aData, aDataLength)
#endif
#if OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump independent of the configured log level.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpAlways(aText, aData, aDataLength) Logger::DumpInModule("", kLogLevelNone, aText, aData, aDataLength)
#endif
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE && OPENTHREAD_CONFIG_LOG_PKT_DUMP
/**
* This macro generates a memory dump for certification test.
*
* @param[in] aText A string that is printed before the bytes.
* @param[in] aData A pointer to the data buffer.
* @param[in] aDataLength Number of bytes in @p aData.
*
*/
#define DumpCert(aText, aData, aDataLength) DumpAlways(aText, aData, aDataLength)
#else
#define DumpCert(aText, aData, aDataLength)
#endif
//----------------------------------------------------------------------------------------------------------------------
class Logger
{
// The `Logger` class implements the logging methods.
//
// The `Logger` methods are not intended to be directly used
// and instead the logging macros should be used.
public:
template <LogLevel kLogLevel, const char *kModuleName, typename... Args>
static void Log(const char *aFormat, Args... aArgs)
{
LogAtLevel<kLogLevel>(kModuleName, aFormat, aArgs...);
}
static void LogInModule(const char *aModuleName, LogLevel aLogLevel, const char *aFormat, ...);
template <LogLevel kLogLevel> static void LogAtLevel(const char *aModuleName, const char *aFormat, ...);
static void LogVarArgs(const char *aModuleName, LogLevel aLogLevel, const char *aFormat, va_list aArgs);
#if OPENTHREAD_CONFIG_LOG_PKT_DUMP
static constexpr uint8_t kStringLineLength = 80;
static constexpr uint8_t kDumpBytesPerLine = 16;
template <LogLevel kLogLevel, const char *kModuleName>
static void Dump(const char *aText, const void *aData, uint16_t aDataLength)
{
DumpAtLevel<kLogLevel>(kModuleName, aText, aData, aDataLength);
}
static void DumpInModule(const char *aModuleName,
LogLevel aLogLevel,
const char *aText,
const void *aData,
uint16_t aDataLength);
template <LogLevel kLogLevel>
static void DumpAtLevel(const char *aModuleName, const char *aText, const void *aData, uint16_t aDataLength);
static void DumpLine(const char *aModuleName, LogLevel aLogLevel, const uint8_t *aData, uint16_t aDataLength);
#endif
};
extern template void Logger::LogAtLevel<kLogLevelNone>(const char *aModuleName, const char *aFormat, ...);
extern template void Logger::LogAtLevel<kLogLevelCrit>(const char *aModuleName, const char *aFormat, ...);
extern template void Logger::LogAtLevel<kLogLevelWarn>(const char *aModuleName, const char *aFormat, ...);
extern template void Logger::LogAtLevel<kLogLevelNote>(const char *aModuleName, const char *aFormat, ...);
extern template void Logger::LogAtLevel<kLogLevelInfo>(const char *aModuleName, const char *aFormat, ...);
extern template void Logger::LogAtLevel<kLogLevelDebg>(const char *aModuleName, const char *aFormat, ...);
#if OPENTHREAD_CONFIG_LOG_PKT_DUMP
extern template void Logger::DumpAtLevel<kLogLevelNone>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
extern template void Logger::DumpAtLevel<kLogLevelCrit>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
extern template void Logger::DumpAtLevel<kLogLevelWarn>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
extern template void Logger::DumpAtLevel<kLogLevelNote>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
extern template void Logger::DumpAtLevel<kLogLevelInfo>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
extern template void Logger::DumpAtLevel<kLogLevelDebg>(const char *aModuleName,
const char *aText,
const void *aData,
uint16_t aDataLength);
#endif
} // namespace ot
#endif // LOG_HPP_
-351
View File
@@ -1,351 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the logging related functions.
*/
#include "logging.hpp"
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/string.hpp"
/*
* Verify debug uart dependency.
*
* It is reasonable to only enable the debug uart and not enable logs to the DEBUG uart.
*/
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && (!OPENTHREAD_CONFIG_ENABLE_DEBUG_UART)
#error "OPENTHREAD_CONFIG_ENABLE_DEBUG_UART_LOG requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART"
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME && !OPENTHREAD_CONFIG_UPTIME_ENABLE
#error "OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME requires OPENTHREAD_CONFIG_UPTIME_ENABLE"
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME && OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#error "OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME is not supported under OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE"
#endif
#ifdef __cplusplus
extern "C" {
#endif
static void Log(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs)
{
ot::String<OPENTHREAD_CONFIG_LOG_MAX_SIZE> logString;
#if OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
ot::Uptime::UptimeToString(ot::Instance::Get().Get<ot::Uptime>().GetUptime(), logString);
logString.Append(" ");
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
VerifyOrExit(otLoggingGetLevel() >= aLogLevel);
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
{
static const char *const kLevelStrings[] = {
"NONE", "CRIT", "WARN", "NOTE", "INFO", "DEBG",
};
uint16_t index = ((aLogLevel >= 0) && (aLogLevel < static_cast<int>(OT_ARRAY_LENGTH(kLevelStrings))))
? static_cast<uint16_t>(aLogLevel)
: 0;
logString.Append("[%s]", kLevelStrings[index]);
}
#endif
#if OPENTHREAD_CONFIG_LOG_PREPEND_REGION
{
static const char *const kRegionStrings[] = {
"-------", "API----", "MLE----", "ARP----", "N-DATA-", "ICMP---", "IP6----", "TCP----",
"MAC----", "MEM----", "NCP----", "MESH-CP", "DIAG---", "PLAT---", "COAP---", "CLI----",
"CORE---", "UTIL---", "BBR----", "MLR----", "DUA----", "BR-----", "SRP----", "DNS----",
};
uint16_t index = (aLogRegion < OT_ARRAY_LENGTH(kRegionStrings)) ? static_cast<uint16_t>(aLogRegion) : 0;
logString.Append("-%s-: ", kRegionStrings[index]);
}
#elif OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
logString.Append(": ");
#endif
logString.AppendVarArgs(aFormat, aArgs);
otPlatLog(aLogLevel, aLogRegion, "%s" OPENTHREAD_CONFIG_LOG_SUFFIX, logString.AsCString());
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
exit:
return;
#endif
}
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT
void _otLogCrit(otLogRegion aRegion, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_CRIT, aRegion, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
void _otLogWarn(otLogRegion aRegion, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_WARN, aRegion, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
void _otLogNote(otLogRegion aRegion, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_NOTE, aRegion, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void _otLogInfo(otLogRegion aRegion, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_INFO, aRegion, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG
void _otLogDebg(otLogRegion aRegion, const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_DEBG, aRegion, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_LOG_MAC
void otLogMac(otLogLevel aLogLevel, const char *aFormat, ...)
{
va_list args;
VerifyOrExit(otLoggingGetLevel() >= aLogLevel);
va_start(args, aFormat);
Log(aLogLevel, OT_LOG_REGION_MAC, aFormat, args);
va_end(args);
exit:
return;
}
void otDumpMacFrame(otLogLevel aLogLevel, const char *aId, const void *aBuf, const size_t aLength)
{
constexpr uint8_t kFixedStringPart = 10; // strlen(" seqno=000")
constexpr uint8_t kSeqnoIdx = 2; // index of the sequence number within aBuf
size_t idLength = strlen(aId) + kFixedStringPart + 1; // allow for the '\0' character
char newId[25];
VerifyOrExit(idLength <= sizeof(newId));
snprintf(newId, idLength, "%s seqno=%03u", aId, static_cast<const uint8_t *>(aBuf)[kSeqnoIdx]);
otDump(aLogLevel, OT_LOG_REGION_MAC, newId, aBuf, aLength);
exit:
return;
}
#endif
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
void otLogCertMeshCoP(const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_NONE, OT_LOG_REGION_MESH_COP, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_OTNS_ENABLE
void otLogOtns(const char *aFormat, ...)
{
va_list args;
va_start(args, aFormat);
Log(OT_LOG_LEVEL_NONE, OT_LOG_REGION_CORE, aFormat, args);
va_end(args);
}
#endif
#if OPENTHREAD_CONFIG_LOG_PKT_DUMP
static void otLogDump(otLogLevel aLogLevel, otLogRegion aRegion, const char *aFormat, ...)
{
va_list args;
VerifyOrExit(otLoggingGetLevel() >= aLogLevel);
va_start(args, aFormat);
Log(aLogLevel, aRegion, aFormat, args);
va_end(args);
exit:
return;
}
static constexpr uint8_t kStringLineLength = 80;
static constexpr uint8_t kDumpBytesPerLine = 16;
static void DumpLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const uint8_t *aBytes, const size_t aLength)
{
ot::String<kStringLineLength> string;
string.Append("|");
for (uint8_t i = 0; i < kDumpBytesPerLine; i++)
{
if (i < aLength)
{
string.Append(" %02X", aBytes[i]);
}
else
{
string.Append(" ..");
}
if (!((i + 1) % 8))
{
string.Append(" |");
}
}
string.Append(" ");
for (uint8_t i = 0; i < kDumpBytesPerLine; i++)
{
char c = '.';
if (i < aLength)
{
char byteAsChar = static_cast<char>(0x7f & aBytes[i]);
if (isprint(byteAsChar))
{
c = byteAsChar;
}
}
string.Append("%c", c);
}
otLogDump(aLogLevel, aLogRegion, "%s", string.AsCString());
}
void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const void *aBuf, const size_t aLength)
{
constexpr uint8_t kWidth = 72;
constexpr uint8_t kFixedStringPart = 10; // strlen("[ len=000]")
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("=");
}
string.Append("[%s len=%03u]", aId, static_cast<unsigned>(aLength));
for (size_t i = 0; i < kWidth - idLen - (kWidth - idLen) / 2; i++)
{
string.Append("=");
}
otLogDump(aLogLevel, aLogRegion, "%s", string.AsCString());
for (size_t i = 0; i < aLength; i += kDumpBytesPerLine)
{
DumpLine(aLogLevel, aLogRegion, static_cast<const uint8_t *>(aBuf) + i,
OT_MIN((aLength - i), static_cast<size_t>(kDumpBytesPerLine)));
}
string.Clear();
for (size_t i = 0; i < kWidth; i++)
{
string.Append("-");
}
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)
{
}
#endif // OPENTHREAD_CONFIG_LOG_PKT_DUMP
#if OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_NONE
/* this provides a stub, in case something uses the function */
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
OT_UNUSED_VARIABLE(aFormat);
}
#endif
OT_TOOL_WEAK void otPlatLogLine(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogLine)
{
otPlatLog(aLogLevel, aLogRegion, "%s", aLogLine);
}
#ifdef __cplusplus
}
#endif
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -39,7 +39,7 @@
#include "common/heap.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "net/checksum.hpp"
#include "net/ip6.hpp"
@@ -55,6 +55,8 @@
namespace ot {
RegisterLogModule("Message");
//---------------------------------------------------------------------------------------------------------------------
// MessagePool
@@ -128,7 +130,7 @@ Buffer *MessagePool::NewBuffer(Message::Priority aPriority)
exit:
if (buffer == nullptr)
{
otLogInfoMem("No available message buffer");
LogInfo("No available message buffer");
}
return buffer;
+9 -8
View File
@@ -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
-1
View File
@@ -37,7 +37,6 @@
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/logging.hpp"
#include "common/random.hpp"
#include "crypto/mbedtls.hpp"
+27 -31
View File
@@ -37,78 +37,78 @@
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/dataset.hpp"
#include "thread/mle.hpp"
namespace ot {
RegisterLogModule("Settings");
//---------------------------------------------------------------------------------------------------------------------
// SettingsBase
// LCOV_EXCL_START
#if OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void SettingsBase::NetworkInfo::Log(Action aAction) const
{
otLogInfoCore(
"[settings] %s NetworkInfo {rloc:0x%04x, extaddr:%s, role:%s, mode:0x%02x, version:%hu, keyseq:0x%x, ...",
ActionToString(aAction), GetRloc16(), GetExtAddress().ToString().AsCString(),
Mle::Mle::RoleToString(static_cast<Mle::DeviceRole>(GetRole())), GetDeviceMode(), GetVersion(),
GetKeySequence());
LogInfo("%s NetworkInfo {rloc:0x%04x, extaddr:%s, role:%s, mode:0x%02x, version:%hu, keyseq:0x%x, ...",
ActionToString(aAction), GetRloc16(), GetExtAddress().ToString().AsCString(),
Mle::Mle::RoleToString(static_cast<Mle::DeviceRole>(GetRole())), GetDeviceMode(), GetVersion(),
GetKeySequence());
otLogInfoCore("[settings] ... pid:0x%x, mlecntr:0x%x, maccntr:0x%x, mliid:%s}", GetPreviousPartitionId(),
GetMleFrameCounter(), GetMacFrameCounter(), GetMeshLocalIid().ToString().AsCString());
LogInfo("... pid:0x%x, mlecntr:0x%x, maccntr:0x%x, mliid:%s}", GetPreviousPartitionId(), GetMleFrameCounter(),
GetMacFrameCounter(), GetMeshLocalIid().ToString().AsCString());
}
void SettingsBase::ParentInfo::Log(Action aAction) const
{
otLogInfoCore("[settings] %s ParentInfo {extaddr:%s, version:%hu}", ActionToString(aAction),
GetExtAddress().ToString().AsCString(), GetVersion());
LogInfo("%s ParentInfo {extaddr:%s, version:%hu}", ActionToString(aAction), GetExtAddress().ToString().AsCString(),
GetVersion());
}
#if OPENTHREAD_FTD
void SettingsBase::ChildInfo::Log(Action aAction) const
{
otLogInfoCore("[settings] %s ChildInfo {rloc:0x%04x, extaddr:%s, timeout:%u, mode:0x%02x, version:%hu}",
ActionToString(aAction), GetRloc16(), GetExtAddress().ToString().AsCString(), GetTimeout(), GetMode(),
GetVersion());
LogInfo("%s ChildInfo {rloc:0x%04x, extaddr:%s, timeout:%u, mode:0x%02x, version:%hu}", ActionToString(aAction),
GetRloc16(), GetExtAddress().ToString().AsCString(), GetTimeout(), GetMode(), GetVersion());
}
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
void SettingsBase::DadInfo::Log(Action aAction) const
{
otLogInfoCore("[settings] %s DadInfo {DadCounter:%2d}", ActionToString(aAction), GetDadCounter());
LogInfo("%s DadInfo {DadCounter:%2d}", ActionToString(aAction), GetDadCounter());
}
#endif
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
void SettingsBase::LogPrefix(Action aAction, Key aKey, const Ip6::Prefix &aPrefix)
{
otLogInfoCore("[settings] %s %s %s", ActionToString(aAction), KeyToString(aKey), aPrefix.ToString().AsCString());
LogInfo("%s %s %s", ActionToString(aAction), KeyToString(aKey), aPrefix.ToString().AsCString());
}
#endif
#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE
void SettingsBase::SrpClientInfo::Log(Action aAction) const
{
otLogInfoCore("[settings] %s SrpClientInfo {Server:[%s]:%u}", ActionToString(aAction),
GetServerAddress().ToString().AsCString(), GetServerPort());
LogInfo("%s SrpClientInfo {Server:[%s]:%u}", ActionToString(aAction), GetServerAddress().ToString().AsCString(),
GetServerPort());
}
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE && OPENTHREAD_CONFIG_SRP_SERVER_PORT_SWITCH_ENABLE
void SettingsBase::SrpServerInfo::Log(Action aAction) const
{
otLogInfoCore("[settings] %s SrpServerInfo {port:%u}", ActionToString(aAction), GetPort());
LogInfo("%s SrpServerInfo {port:%u}", ActionToString(aAction), GetPort());
}
#endif
#endif // OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)
#endif // OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
#if OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
const char *SettingsBase::ActionToString(Action aAction)
{
static const char *const kActionStrings[] = {
@@ -135,9 +135,9 @@ const char *SettingsBase::ActionToString(Action aAction)
return kActionStrings[aAction];
}
#endif // OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)
#endif // OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
#if OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
const char *SettingsBase::KeyToString(Key aKey)
{
static const char *const kKeyStrings[] = {
@@ -179,7 +179,7 @@ const char *SettingsBase::KeyToString(Key aKey)
return kKeyStrings[aKey];
}
#endif // OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN)
#endif // OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
// LCOV_EXCL_STOP
@@ -207,7 +207,7 @@ void Settings::Deinit(void)
void Settings::Wipe(void)
{
Get<SettingsDriver>().Wipe();
otLogInfoCore("[settings] Wiped all info");
LogInfo("Wiped all info");
}
Error Settings::SaveOperationalDataset(bool aIsActive, const MeshCoP::Dataset &aDataset)
@@ -356,8 +356,6 @@ void Settings::Log(Action aAction, Error aError, Key aKey, const void *aValue)
OT_UNUSED_VARIABLE(aError);
OT_UNUSED_VARIABLE(aValue);
#if OPENTHREAD_CONFIG_LOG_UTIL
if (aError != kErrorNone)
{
// Log error if log level is at "warn" or higher.
@@ -396,7 +394,7 @@ void Settings::Log(Action aAction, Error aError, Key aKey, const void *aValue)
ExitNow();
}
otLogWarnCore("[settings] Error %s %s %s", ErrorToString(aError), actionText, KeyToString(aKey));
LogWarn("Error %s %s %s", ErrorToString(aError), actionText, KeyToString(aKey));
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN)
@@ -463,13 +461,11 @@ void Settings::Log(Action aAction, Error aError, Key aKey, const void *aValue)
if (aValue == nullptr)
{
otLogInfoCore("[settings] %s %s", ActionToString(aAction), KeyToString(aKey));
LogInfo("%s %s", ActionToString(aAction), KeyToString(aKey));
}
#endif // (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)
exit:
#endif // OPENTHREAD_CONFIG_LOG_UTIL
return;
}
+2 -2
View File
@@ -744,10 +744,10 @@ protected:
static void LogPrefix(Action aAction, Key aKey, const Ip6::Prefix &aPrefix);
#endif
#if OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
static const char *KeyToString(Key aKey);
#endif
#if OPENTHREAD_CONFIG_LOG_UTIL && (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
static const char *ActionToString(Action aAction);
#endif
};
-1
View File
@@ -38,7 +38,6 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
namespace ot {
+6 -222
View File
@@ -103,140 +103,20 @@
#define OPENTHREAD_CONFIG_LOG_LEVEL_INIT OPENTHREAD_CONFIG_LOG_LEVEL
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_API
*
* Define to enable OpenThread API logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_API
#define OPENTHREAD_CONFIG_LOG_API 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_MLE
*
* Define to enable MLE logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_MLE
#define OPENTHREAD_CONFIG_LOG_MLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_MESHCOP
*
* Define to enable MeshCoP logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_MESHCOP
#define OPENTHREAD_CONFIG_LOG_MESHCOP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_ARP
*
* Define to enable EID-to-RLOC map logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_ARP
#define OPENTHREAD_CONFIG_LOG_ARP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_NETDATA
*
* Define to enable Network Data logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_NETDATA
#define OPENTHREAD_CONFIG_LOG_NETDATA 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_ICMP
*
* Define to enable ICMPv6 logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_ICMP
#define OPENTHREAD_CONFIG_LOG_ICMP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_IP6
*
* Define to enable IPv6 logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_IP6
#define OPENTHREAD_CONFIG_LOG_IP6 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_TCP
*
* Define to enable IPv6 logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_TCP
#define OPENTHREAD_CONFIG_LOG_TCP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_MAC
*
* Define to enable IEEE 802.15.4 MAC logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_MAC
#define OPENTHREAD_CONFIG_LOG_MAC 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_MEM
*
* Define to enable memory logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_MEM
#define OPENTHREAD_CONFIG_LOG_MEM 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_PKT_DUMP
*
* Define to enable log content of packets.
* Define to enable dump logs (of packets).
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_NETDIAG
*
* Define to enable network diagnostic logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_NETDIAG
#define OPENTHREAD_CONFIG_LOG_NETDIAG 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_PLATFORM
*
* Define to enable platform region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_PLATFORM
#define OPENTHREAD_CONFIG_LOG_PLATFORM 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_CLI
*
* Define to enable CLI logging.
* Define to enable CLI logging and `otLogCli()` OT function.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_CLI
@@ -244,99 +124,13 @@
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_COAP
* @def OPENTHREAD_CONFIG_LOG_PLATFORM
*
* Define to enable COAP logging.
* Define to enable platform logging and `otLog{Level}Plat()` OT functions.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_COAP
#define OPENTHREAD_CONFIG_LOG_COAP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_CORE
*
* Define to enable OpenThread Core logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_CORE
#define OPENTHREAD_CONFIG_LOG_CORE 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_UTIL
*
* Define to enable OpenThread Utility module logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_UTIL
#define OPENTHREAD_CONFIG_LOG_UTIL 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_BBR
*
* Note: available since Thread 1.2.
*
* Define to enable Backbone Router (BBR) region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_BBR
#define OPENTHREAD_CONFIG_LOG_BBR 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_MLR
*
* Note: available since Thread 1.2.
*
* Define to enable Multicast Listener Registration (MLR) region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_MLR
#define OPENTHREAD_CONFIG_LOG_MLR 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_DUA
*
* Note: available since Thread 1.2.
*
* Define to enable Domain Unicast Address (DUA) region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_DUA
#define OPENTHREAD_CONFIG_LOG_DUA 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_BR
*
* Define to Border Router (BR) region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_BR
#define OPENTHREAD_CONFIG_LOG_BR 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_SRP
*
* Define to enable Service Registration Protocol (SRP) region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_SRP
#define OPENTHREAD_CONFIG_LOG_SRP 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_DNS
*
* Define to enable DNS region logging.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_DNS
#define OPENTHREAD_CONFIG_LOG_DNS 1
#ifndef OPENTHREAD_CONFIG_LOG_PLATFORM
#define OPENTHREAD_CONFIG_LOG_PLATFORM 1
#endif
/**
@@ -359,16 +153,6 @@
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_PREPEND_REGION
*
* Define to prepend the log region to all log messages.
*
*/
#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_REGION
#define OPENTHREAD_CONFIG_LOG_PREPEND_REGION 1
#endif
/**
* @def OPENTHREAD_CONFIG_LOG_SUFFIX
*
@@ -530,4 +530,88 @@
#error "OPENTHREAD_CONFIG_UNSECURE_TRAFFIC_MANAGED_BY_STACK_ENABLE was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_API
#error "OPENTHREAD_CONFIG_LOG_API was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_MLE
#error "OPENTHREAD_CONFIG_LOG_MLE was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_MESHCOP
#error "OPENTHREAD_CONFIG_LOG_MESHCOP was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_ARP
#error "OPENTHREAD_CONFIG_LOG_ARP was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_NETDATA
#error "OPENTHREAD_CONFIG_LOG_NETDATA was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_ICMP
#error "OPENTHREAD_CONFIG_LOG_ICMP was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_IP6
#error "OPENTHREAD_CONFIG_LOG_IP6 was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_TCP
#error "OPENTHREAD_CONFIG_LOG_TCP was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_MAC
#error "OPENTHREAD_CONFIG_LOG_MAC was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_MEM
#error "OPENTHREAD_CONFIG_LOG_MEM was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_NETDIAG
#error "OPENTHREAD_CONFIG_LOG_NETDIAG was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_COAP
#error "OPENTHREAD_CONFIG_LOG_COAP was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_CORE
#error "OPENTHREAD_CONFIG_LOG_CORE was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_UTIL
#error "OPENTHREAD_CONFIG_LOG_UTIL was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_BBR
#error "OPENTHREAD_CONFIG_LOG_BBR was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_MLR
#error "OPENTHREAD_CONFIG_LOG_MLR was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_DUA
#error "OPENTHREAD_CONFIG_LOG_DUA was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_BR
#error "OPENTHREAD_CONFIG_LOG_BR was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_SRP
#error "OPENTHREAD_CONFIG_LOG_SRP was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_DNS
#error "OPENTHREAD_CONFIG_LOG_DNS was removed and no longer supported"
#endif
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION
#error "OPENTHREAD_CONFIG_LOG_PREPEND_REGION was removed and not longer supported"
#endif
#endif // OPENTHREAD_CORE_CONFIG_CHECK_H_
+7 -5
View File
@@ -38,10 +38,12 @@
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
namespace ot {
RegisterLogModule("DataPollHandlr");
DataPollHandler::Callbacks::Callbacks(Instance &aInstance)
: InstanceLocator(aInstance)
{
@@ -144,8 +146,8 @@ void DataPollHandler::HandleDataPoll(Mac::RxFrame &aFrame)
indirectMsgCount = child->GetIndirectMessageCount();
otLogInfoMac("Rx data poll, src:0x%04x, qed_msgs:%d, rss:%d, ack-fp:%d", child->GetRloc16(), indirectMsgCount,
aFrame.GetRssi(), aFrame.IsAckedWithFramePending());
LogInfo("Rx data poll, src:0x%04x, qed_msgs:%d, rss:%d, ack-fp:%d", child->GetRloc16(), indirectMsgCount,
aFrame.GetRssi(), aFrame.IsAckedWithFramePending());
if (!aFrame.IsAckedWithFramePending())
{
@@ -245,8 +247,8 @@ void DataPollHandler::HandleSentFrame(const Mac::TxFrame &aFrame, Error aError,
OT_ASSERT(!aFrame.GetSecurityEnabled() || aFrame.IsHeaderUpdated());
aChild.IncrementIndirectTxAttempts();
otLogInfoMac("Indirect tx to child %04x failed, attempt %d/%d", aChild.GetRloc16(),
aChild.GetIndirectTxAttempts(), kMaxPollTriggeredTxAttempts);
LogInfo("Indirect tx to child %04x failed, attempt %d/%d", aChild.GetRloc16(), aChild.GetIndirectTxAttempts(),
kMaxPollTriggeredTxAttempts);
OT_FALL_THROUGH;
+13 -11
View File
@@ -36,7 +36,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/message.hpp"
#include "net/ip6.hpp"
#include "net/netif.hpp"
@@ -46,6 +46,8 @@
namespace ot {
RegisterLogModule("DataPollSender");
DataPollSender::DataPollSender(Instance &aInstance)
: InstanceLocator(aInstance)
, mTimerStartTime(0)
@@ -112,22 +114,22 @@ exit:
switch (error)
{
case kErrorNone:
otLogDebgMac("Sending data poll");
LogDebg("Sending data poll");
ScheduleNextPoll(kUsePreviousPollPeriod);
break;
case kErrorInvalidState:
otLogWarnMac("Data poll tx requested while data polling was not enabled!");
LogWarn("Data poll tx requested while data polling was not enabled!");
StopPolling();
break;
case kErrorAlready:
otLogDebgMac("Data poll tx requested when a previous data request still in send queue.");
LogDebg("Data poll tx requested when a previous data request still in send queue.");
ScheduleNextPoll(kUsePreviousPollPeriod);
break;
default:
otLogWarnMac("Unexpected error %s requesting data poll", ErrorToString(error));
LogWarn("Unexpected error %s requesting data poll", ErrorToString(error));
ScheduleNextPoll(kRecalculatePollPeriod);
break;
}
@@ -260,12 +262,12 @@ void DataPollSender::HandlePollSent(Mac::TxFrame &aFrame, Error aError)
mPollTxFailureCounter++;
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
otLogInfoMac("Failed to send data poll, error:%s, retx:%d/%d", ErrorToString(aError), mPollTxFailureCounter,
(aFrame.GetHeaderIe(Mac::CslIe::kHeaderIeId) != nullptr) ? kMaxCslPollRetxAttempts
: kMaxPollRetxAttempts);
LogInfo("Failed to send data poll, error:%s, retx:%d/%d", ErrorToString(aError), mPollTxFailureCounter,
(aFrame.GetHeaderIe(Mac::CslIe::kHeaderIeId) != nullptr) ? kMaxCslPollRetxAttempts
: kMaxPollRetxAttempts);
#else
otLogInfoMac("Failed to send data poll, error:%s, retx:%d/%d", ErrorToString(aError), mPollTxFailureCounter,
kMaxPollRetxAttempts);
LogInfo("Failed to send data poll, error:%s, retx:%d/%d", ErrorToString(aError), mPollTxFailureCounter,
kMaxPollRetxAttempts);
#endif
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
@@ -310,7 +312,7 @@ void DataPollSender::HandlePollTimeout(void)
mPollTimeoutCounter++;
otLogInfoMac("Data poll timeout, retry:%d/%d", mPollTimeoutCounter, kQuickPollsAfterTimeout);
LogInfo("Data poll timeout, retry:%d/%d", mPollTimeoutCounter, kQuickPollsAfterTimeout);
if (mPollTimeoutCounter < kQuickPollsAfterTimeout)
{
+9 -8
View File
@@ -42,13 +42,15 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "mac/mac_frame.hpp"
namespace ot {
namespace Mac {
RegisterLogModule("LinkRaw");
LinkRaw::LinkRaw(Instance &aInstance)
: InstanceLocator(aInstance)
, mReceiveChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL)
@@ -84,7 +86,7 @@ Error LinkRaw::SetReceiveDone(otLinkRawReceiveDone aCallback)
Error error = kErrorNone;
bool enable = aCallback != nullptr;
otLogDebgMac("LinkRaw::Enabled(%s)", (enable ? "true" : "false"));
LogDebg("Enabled(%s)", (enable ? "true" : "false"));
#if OPENTHREAD_MTD || OPENTHREAD_FTD
VerifyOrExit(!Get<ThreadNetif>().IsUp(), error = kErrorInvalidState);
@@ -179,8 +181,7 @@ exit:
void LinkRaw::InvokeReceiveDone(RxFrame *aFrame, Error aError)
{
otLogDebgMac("LinkRaw::ReceiveDone(%d bytes), error:%s", (aFrame != nullptr) ? aFrame->mLength : 0,
ErrorToString(aError));
LogDebg("ReceiveDone(%d bytes), error:%s", (aFrame != nullptr) ? aFrame->mLength : 0, ErrorToString(aError));
if (mReceiveDoneCallback && (aError == kErrorNone))
{
@@ -203,7 +204,7 @@ exit:
void LinkRaw::InvokeTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
{
otLogDebgMac("LinkRaw::TransmitDone(%d bytes), error:%s", aFrame.mLength, ErrorToString(aError));
LogDebg("TransmitDone(%d bytes), error:%s", aFrame.mLength, ErrorToString(aError));
if (mTransmitDoneCallback)
{
@@ -270,7 +271,7 @@ exit:
// LCOV_EXCL_START
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void LinkRaw::RecordFrameTransmitStatus(const TxFrame &aFrame,
const RxFrame *aAckFrame,
@@ -283,8 +284,8 @@ void LinkRaw::RecordFrameTransmitStatus(const TxFrame &aFrame,
if (aError != kErrorNone)
{
otLogInfoMac("Frame tx failed, error:%s, retries:%d/%d, %s", ErrorToString(aError), aRetryCount,
aFrame.GetMaxFrameRetries(), aFrame.ToInfoString().AsCString());
LogInfo("Frame tx failed, error:%s, retries:%d/%d, %s", ErrorToString(aError), aRetryCount,
aFrame.GetMaxFrameRetries(), aFrame.ToInfoString().AsCString());
}
}
+1 -1
View File
@@ -294,7 +294,7 @@ public:
* when there was an error in transmission (i.e., `aError` is not NONE).
*
*/
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void RecordFrameTransmitStatus(const TxFrame &aFrame,
const RxFrame *aAckFrame,
Error aError,
+43 -41
View File
@@ -42,7 +42,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "common/string.hpp"
#include "crypto/aes_ccm.hpp"
@@ -58,6 +58,8 @@
namespace ot {
namespace Mac {
RegisterLogModule("Mac");
const otExtAddress Mac::sMode2ExtAddress = {
{0x35, 0x06, 0xfe, 0xb8, 0x23, 0xd4, 0x87, 0x12},
};
@@ -594,7 +596,7 @@ void Mac::UpdateIdleMode(void)
mTimer.Start(kSleepDelay);
mShouldDelaySleep = false;
mDelayingSleep = true;
otLogDebgMac("Idle mode: Sleep delayed");
LogDebg("Idle mode: Sleep delayed");
}
if (mDelayingSleep)
@@ -620,12 +622,12 @@ void Mac::UpdateIdleMode(void)
}
#endif
mLinks.Sleep();
otLogDebgMac("Idle mode: Radio sleeping");
LogDebg("Idle mode: Radio sleeping");
}
else
{
mLinks.Receive(mRadioChannel);
otLogDebgMac("Idle mode: Radio receiving on channel %d", mRadioChannel);
LogDebg("Idle mode: Radio receiving on channel %d", mRadioChannel);
}
exit:
@@ -643,12 +645,12 @@ void Mac::StartOperation(Operation aOperation)
{
SetPending(aOperation);
otLogDebgMac("Request to start operation \"%s\"", OperationToString(aOperation));
LogDebg("Request to start operation \"%s\"", OperationToString(aOperation));
#if OPENTHREAD_CONFIG_MAC_STAY_AWAKE_BETWEEN_FRAGMENTS
if (mDelayingSleep)
{
otLogDebgMac("Canceling sleep delay");
LogDebg("Canceling sleep delay");
mTimer.Stop();
mDelayingSleep = false;
mShouldDelaySleep = false;
@@ -732,7 +734,7 @@ void Mac::PerformNextOperation(void)
if (mOperation != kOperationIdle)
{
ClearPending(mOperation);
otLogDebgMac("Starting operation \"%s\"", OperationToString(mOperation));
LogDebg("Starting operation \"%s\"", OperationToString(mOperation));
mTimer.Stop(); // Stop the timer before any non-idle operation, have the operation itself be responsible to
// start the timer (if it wants to).
}
@@ -775,7 +777,7 @@ exit:
void Mac::FinishOperation(void)
{
otLogDebgMac("Finishing operation \"%s\"", OperationToString(mOperation));
LogDebg("Finishing operation \"%s\"", OperationToString(mOperation));
mOperation = kOperationIdle;
}
@@ -789,7 +791,7 @@ TxFrame *Mac::PrepareBeaconRequest(void)
frame.SetDstAddr(kShortAddrBroadcast);
IgnoreError(frame.SetCommandId(Frame::kMacCmdBeaconRequest));
otLogInfoMac("Sending Beacon Request");
LogInfo("Sending Beacon Request");
return &frame;
}
@@ -1140,7 +1142,7 @@ void Mac::BeginTransmit(void)
if (!mRxOnWhenIdle && !mPromiscuous)
{
mShouldDelaySleep = frame->GetFramePending();
otLogDebgMac("Delay sleep for pending tx");
LogDebg("Delay sleep for pending tx");
}
#endif
@@ -1233,7 +1235,7 @@ void Mac::RecordFrameTransmitStatus(const TxFrame &aFrame,
if (aError != kErrorNone)
{
LogFrameTxFailure(aFrame, aError, aRetryCount, aWillRetx);
otDumpDebgMac("TX ERR", aFrame.GetHeader(), 16);
DumpDebg("TX ERR", aFrame.GetHeader(), 16);
if (aWillRetx)
{
@@ -1386,8 +1388,8 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
if (requriedRadios.Contains(radio) && (aError != kErrorNone))
{
otLogDebgMac("Frame tx failed on required radio link %s with error %s", RadioTypeToString(radio),
ErrorToString(aError));
LogDebg("Frame tx failed on required radio link %s with error %s", RadioTypeToString(radio),
ErrorToString(aError));
mTxError = aError;
}
@@ -1430,7 +1432,7 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
StartOperation(kOperationWaitingForData);
}
otLogInfoMac("Sent data poll, fp:%s", ToYesNo(framePending));
LogInfo("Sent data poll, fp:%s", ToYesNo(framePending));
}
mCounters.mTxDataPoll++;
@@ -1453,7 +1455,7 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
}
#endif
otDumpDebgMac("TX", aFrame.GetHeader(), aFrame.GetLength());
DumpDebg("TX", aFrame.GetHeader(), aFrame.GetLength());
FinishOperation();
Get<MeshForwarder>().HandleSentFrame(aFrame, aError);
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
@@ -1467,7 +1469,7 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
case kOperationTransmitDataCsl:
mCounters.mTxData++;
otDumpDebgMac("TX", aFrame.GetHeader(), aFrame.GetLength());
DumpDebg("TX", aFrame.GetHeader(), aFrame.GetLength());
FinishOperation();
Get<CslTxScheduler>().HandleSentFrame(aFrame, aError);
PerformNextOperation();
@@ -1488,7 +1490,7 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
}
#endif
otDumpDebgMac("TX", aFrame.GetHeader(), aFrame.GetLength());
DumpDebg("TX", aFrame.GetHeader(), aFrame.GetLength());
FinishOperation();
Get<DataPollHandler>().HandleSentFrame(aFrame, aError);
PerformNextOperation();
@@ -1519,7 +1521,7 @@ void Mac::HandleTimer(void)
break;
case kOperationWaitingForData:
otLogDebgMac("Data poll timeout");
LogDebg("Data poll timeout");
FinishOperation();
Get<DataPollSender>().HandlePollTimeout();
PerformNextOperation();
@@ -1531,7 +1533,7 @@ void Mac::HandleTimer(void)
#if OPENTHREAD_CONFIG_MAC_STAY_AWAKE_BETWEEN_FRAGMENTS
if (mDelayingSleep)
{
otLogDebgMac("Sleep delay timeout expired");
LogDebg("Sleep delay timeout expired");
mDelayingSleep = false;
UpdateIdleMode();
}
@@ -1568,7 +1570,7 @@ Error Mac::ProcessReceiveSecurity(RxFrame &aFrame, const Address &aSrcAddr, Neig
VerifyOrExit(securityLevel == Frame::kSecEncMic32);
IgnoreError(aFrame.GetFrameCounter(frameCounter));
otLogDebgMac("Rx security - frame counter %u", frameCounter);
LogDebg("Rx security - frame counter %u", frameCounter);
IgnoreError(aFrame.GetKeyIdMode(keyIdMode));
@@ -1714,7 +1716,7 @@ Error Mac::ProcessEnhAckSecurity(TxFrame &aTxFrame, RxFrame &aAckFrame)
VerifyOrExit(txKeyId == ackKeyId);
IgnoreError(aAckFrame.GetFrameCounter(frameCounter));
otLogDebgMac("Rx security - Ack frame counter %u", frameCounter);
LogDebg("Rx security - Ack frame counter %u", frameCounter);
IgnoreError(aAckFrame.GetSrcAddr(srcAddr));
@@ -1775,7 +1777,7 @@ Error Mac::ProcessEnhAckSecurity(TxFrame &aTxFrame, RxFrame &aAckFrame)
exit:
if (error != kErrorNone)
{
otLogInfoMac("Frame tx attempt failed, error: Enh-ACK security check fail");
LogInfo("Frame tx attempt failed, error: Enh-ACK security check fail");
}
return error;
@@ -1842,7 +1844,7 @@ void Mac::HandleReceivedFrame(RxFrame *aFrame, Error aError)
break;
case Address::kTypeShort:
otLogDebgMac("Received frame from short address 0x%04x", srcaddr.GetShort());
LogDebg("Received frame from short address 0x%04x", srcaddr.GetShort());
VerifyOrExit(neighbor != nullptr, error = kErrorUnknownNeighbor);
@@ -2005,7 +2007,7 @@ void Mac::HandleReceivedFrame(RxFrame *aFrame, Error aError)
if (!mRxOnWhenIdle && !mPromiscuous && aFrame->GetFramePending())
{
mShouldDelaySleep = true;
otLogDebgMac("Delay sleep for pending rx");
LogDebg("Delay sleep for pending rx");
}
#endif
FinishOperation();
@@ -2043,7 +2045,7 @@ void Mac::HandleReceivedFrame(RxFrame *aFrame, Error aError)
ExitNow();
}
otDumpDebgMac("RX", aFrame->GetHeader(), aFrame->GetLength());
DumpDebg("RX", aFrame->GetHeader(), aFrame->GetLength());
Get<MeshForwarder>().HandleReceivedFrame(*aFrame);
UpdateIdleMode();
@@ -2106,7 +2108,7 @@ bool Mac::HandleMacCommand(RxFrame &aFrame)
{
case Frame::kMacCmdBeaconRequest:
mCounters.mRxBeaconRequest++;
otLogInfoMac("Received Beacon Request");
LogInfo("Received Beacon Request");
if (ShouldSendBeacon())
{
@@ -2188,7 +2190,7 @@ void Mac::ResetRetrySuccessHistogram()
// LCOV_EXCL_START
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
const char *Mac::OperationToString(Operation aOperation)
{
@@ -2227,28 +2229,28 @@ const char *Mac::OperationToString(Operation aOperation)
void Mac::LogFrameRxFailure(const RxFrame *aFrame, Error aError) const
{
otLogLevel logLevel;
LogLevel logLevel;
switch (aError)
{
case kErrorAbort:
case kErrorNoFrameReceived:
case kErrorDestinationAddressFiltered:
logLevel = OT_LOG_LEVEL_DEBG;
logLevel = kLogLevelDebg;
break;
default:
logLevel = OT_LOG_LEVEL_INFO;
logLevel = kLogLevelInfo;
break;
}
if (aFrame == nullptr)
{
otLogMac(logLevel, "Frame rx failed, error:%s", ErrorToString(aError));
LogAt(logLevel, "Frame rx failed, error:%s", ErrorToString(aError));
}
else
{
otLogMac(logLevel, "Frame rx failed, error:%s, %s", ErrorToString(aError), aFrame->ToInfoString().AsCString());
LogAt(logLevel, "Frame rx failed, error:%s, %s", ErrorToString(aError), aFrame->ToInfoString().AsCString());
}
}
@@ -2265,21 +2267,21 @@ void Mac::LogFrameTxFailure(const TxFrame &aFrame, Error aError, uint8_t aRetryC
uint8_t maxAttempts = aFrame.GetMaxFrameRetries() + 1;
uint8_t curAttempt = aWillRetx ? (aRetryCount + 1) : maxAttempts;
otLogInfoMac("Frame tx attempt %d/%d failed, error:%s, %s", curAttempt, maxAttempts, ErrorToString(aError),
aFrame.ToInfoString().AsCString());
LogInfo("Frame tx attempt %d/%d failed, error:%s, %s", curAttempt, maxAttempts, ErrorToString(aError),
aFrame.ToInfoString().AsCString());
}
else
{
otLogInfoMac("Frame tx failed, error:%s, %s", ErrorToString(aError), aFrame.ToInfoString().AsCString());
LogInfo("Frame tx failed, error:%s, %s", ErrorToString(aError), aFrame.ToInfoString().AsCString());
}
}
void Mac::LogBeacon(const char *aActionText, const BeaconPayload &aBeaconPayload) const
{
otLogInfoMac("%s Beacon, %s", aActionText, aBeaconPayload.ToInfoString().AsCString());
LogInfo("%s Beacon, %s", aActionText, aBeaconPayload.ToInfoString().AsCString());
}
#else // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#else // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void Mac::LogFrameRxFailure(const RxFrame *, Error) const
{
@@ -2293,7 +2295,7 @@ void Mac::LogFrameTxFailure(const TxFrame &, Error, uint8_t, bool) const
{
}
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#endif // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
// LCOV_EXCL_STOP
@@ -2381,9 +2383,9 @@ void Mac::ProcessCsl(const RxFrame &aFrame, const Address &aSrcAddr)
child->SetCslSynchronized(true);
child->SetCslLastHeard(TimerMilli::GetNow());
child->SetLastRxTimestamp(aFrame.GetTimestamp());
otLogDebgMac("Timestamp=%u Sequence=%u CslPeriod=%hu CslPhase=%hu TransmitPhase=%hu",
static_cast<uint32_t>(aFrame.GetTimestamp()), aFrame.GetSequence(), csl->GetPeriod(), csl->GetPhase(),
child->GetCslPhase());
LogDebg("Timestamp=%u Sequence=%u CslPeriod=%hu CslPhase=%hu TransmitPhase=%hu",
static_cast<uint32_t>(aFrame.GetTimestamp()), aFrame.GetSequence(), csl->GetPeriod(), csl->GetPhase(),
child->GetCslPhase());
Get<CslTxScheduler>().Update();
+2 -2
View File
@@ -1379,7 +1379,7 @@ exit:
// LCOV_EXCL_START
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
Frame::InfoString Frame::ToInfoString(void) const
{
@@ -1459,7 +1459,7 @@ BeaconPayload::InfoString BeaconPayload::ToInfoString(void) const
return string;
}
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && (OPENTHREAD_CONFIG_LOG_MAC == 1)
#endif // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
// LCOV_EXCL_STOP
+18 -16
View File
@@ -41,7 +41,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "common/time.hpp"
#include "mac/mac_frame.hpp"
@@ -49,6 +49,8 @@
namespace ot {
namespace Mac {
RegisterLogModule("SubMac");
SubMac::SubMac(Instance &aInstance)
: InstanceLocator(aInstance)
, mRadioCaps(Get<Radio>().GetCaps())
@@ -147,14 +149,14 @@ otRadioCaps SubMac::GetCaps(void) const
void SubMac::SetPanId(PanId aPanId)
{
Get<Radio>().SetPanId(aPanId);
otLogDebgMac("RadioPanId: 0x%04x", aPanId);
LogDebg("RadioPanId: 0x%04x", aPanId);
}
void SubMac::SetShortAddress(ShortAddress aShortAddress)
{
mShortAddress = aShortAddress;
Get<Radio>().SetShortAddress(mShortAddress);
otLogDebgMac("RadioShortAddress: 0x%04x", mShortAddress);
LogDebg("RadioShortAddress: 0x%04x", mShortAddress);
}
void SubMac::SetExtAddress(const ExtAddress &aExtAddress)
@@ -167,7 +169,7 @@ void SubMac::SetExtAddress(const ExtAddress &aExtAddress)
address.Set(aExtAddress.m8, ExtAddress::kReverseByteOrder);
Get<Radio>().SetExtendedAddress(address);
otLogDebgMac("RadioExtAddress: %s", mExtAddress.ToString().AsCString());
LogDebg("RadioExtAddress: %s", mExtAddress.ToString().AsCString());
}
void SubMac::SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext)
@@ -211,7 +213,7 @@ Error SubMac::Sleep(void)
if (error != kErrorNone)
{
otLogWarnMac("RadioSleep() failed, error: %s", ErrorToString(error));
LogWarn("RadioSleep() failed, error: %s", ErrorToString(error));
ExitNow();
}
@@ -238,7 +240,7 @@ Error SubMac::Receive(uint8_t aChannel)
if (error != kErrorNone)
{
otLogWarnMac("RadioReceive() failed, error: %s", ErrorToString(error));
LogWarn("RadioReceive() failed, error: %s", ErrorToString(error));
ExitNow();
}
@@ -283,7 +285,7 @@ Error SubMac::CslSample(uint8_t aPanChannel)
exit:
if (error != kErrorNone)
{
otLogWarnMac("CslSample() failed, error: %s", ErrorToString(error));
LogWarn("CslSample() failed, error: %s", ErrorToString(error));
}
return error;
}
@@ -312,10 +314,10 @@ void SubMac::HandleReceiveDone(RxFrame *aFrame, Error aError)
#if OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE
// Split the log into two lines for RTT to output
otLogDebgMac("Received frame in state (SubMac %s, CSL %s), timestamp %u", StateToString(mState),
CslStateToString(mCslState), static_cast<uint32_t>(aFrame->mInfo.mRxInfo.mTimestamp));
otLogDebgMac("Target sample start time %u, time drift %d", mCslSampleTime.GetValue(),
static_cast<uint32_t>(aFrame->mInfo.mRxInfo.mTimestamp) - mCslSampleTime.GetValue());
LogDebg("Received frame in state (SubMac %s, CSL %s), timestamp %u", StateToString(mState),
CslStateToString(mCslState), static_cast<uint32_t>(aFrame->mInfo.mRxInfo.mTimestamp));
LogDebg("Target sample start time %u, time drift %d", mCslSampleTime.GetValue(),
static_cast<uint32_t>(aFrame->mInfo.mRxInfo.mTimestamp) - mCslSampleTime.GetValue());
#endif
}
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
@@ -762,7 +764,7 @@ void SubMac::HandleTimer(void)
break;
case kStateTransmit:
otLogDebgMac("Ack timer timed out");
LogDebg("Ack timer timed out");
IgnoreError(Get<Radio>().Receive(mTransmitFrame.GetChannel()));
HandleTransmitDone(mTransmitFrame, nullptr, kErrorNoAck);
break;
@@ -888,7 +890,7 @@ void SubMac::SetState(State aState)
{
if (mState != aState)
{
otLogDebgMac("RadioState: %s -> %s", StateToString(mState), StateToString(aState));
LogDebg("RadioState: %s -> %s", StateToString(mState), StateToString(aState));
mState = aState;
}
}
@@ -1047,7 +1049,7 @@ void SubMac::SetCslPeriod(uint16_t aPeriod)
}
}
otLogDebgMac("CSL Period: %u", mCslPeriod);
LogDebg("CSL Period: %u", mCslPeriod);
exit:
return;
@@ -1085,7 +1087,7 @@ void SubMac::HandleCslTimer(void)
#if !OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE
IgnoreError(Get<Radio>().Sleep()); // Don't actually sleep for debugging
#endif
otLogDebgMac("CSL sleep %u", mCslTimer.GetNow().GetValue());
LogDebg("CSL sleep %u", mCslTimer.GetNow().GetValue());
}
break;
@@ -1114,7 +1116,7 @@ void SubMac::HandleCslTimer(void)
else
{
IgnoreError(Get<Radio>().Receive(mCslChannel));
otLogDebgMac("CSL sample %u, duration %u", mCslTimer.GetNow().GetValue(), timeAhead + timeAfter);
LogDebg("CSL sample %u, duration %u", mCslTimer.GetNow().GetValue(), timeAhead + timeAfter);
}
}
break;
+4 -2
View File
@@ -40,7 +40,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/thread_netif.hpp"
@@ -48,6 +48,8 @@
namespace ot {
RegisterLogModule("MeshCoP");
AnnounceBeginClient::AnnounceBeginClient(Instance &aInstance)
: InstanceLocator(aInstance)
{
@@ -85,7 +87,7 @@ Error AnnounceBeginClient::SendRequest(uint32_t aChannelMask,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent announce begin query");
LogInfo("sent announce begin query");
exit:
FreeMessageOnError(message, error);
+18 -16
View File
@@ -40,7 +40,7 @@
#include "common/heap.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/thread_netif.hpp"
@@ -50,6 +50,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("BorderAgent");
namespace {
constexpr uint16_t kBorderAgentUdpPort = OPENTHREAD_CONFIG_BORDER_AGENT_UDP_PORT; ///< UDP port of border agent service.
}
@@ -191,8 +193,8 @@ void BorderAgent::HandleCoapResponse(ForwardContext &aForwardContext, const Coap
Get<ThreadNetif>().AddUnicastAddress(mCommissionerAloc);
IgnoreError(Get<Ip6::Udp>().AddReceiver(mUdpReceiver));
otLogInfoMeshCoP("commissioner accepted: session ID=%d, ALOC=%s", sessionId,
mCommissionerAloc.GetAddress().ToString().AsCString());
LogInfo("commissioner accepted: session ID=%d, ALOC=%s", sessionId,
mCommissionerAloc.GetAddress().ToString().AsCString());
}
}
@@ -211,7 +213,7 @@ exit:
{
FreeMessage(message);
otLogWarnMeshCoP("Commissioner request[%hu] failed: %s", aForwardContext.GetMessageId(), ErrorToString(error));
LogWarn("Commissioner request[%hu] failed: %s", aForwardContext.GetMessageId(), ErrorToString(error));
SendErrorMessage(aForwardContext, error);
}
@@ -343,7 +345,7 @@ void BorderAgent::HandleProxyTransmit(const Coap::Message &aMessage)
SuccessOrExit(error = Get<Ip6::Udp>().SendDatagram(*message, messageInfo, Ip6::kProtoUdp));
mUdpProxyPort = tlv.GetSourcePort();
otLogInfoMeshCoP("Proxy transmit sent to %s", messageInfo.GetPeerAddr().ToString().AsCString());
LogInfo("Proxy transmit sent to %s", messageInfo.GetPeerAddr().ToString().AsCString());
exit:
FreeMessageOnError(message, error);
@@ -386,7 +388,7 @@ bool BorderAgent::HandleUdpReceive(const Message &aMessage, const Ip6::MessageIn
SuccessOrExit(error = Get<Coap::CoapSecure>().SendMessage(*message, Get<Coap::CoapSecure>().GetMessageInfo()));
otLogInfoMeshCoP("Sent to commissioner on %s", UriPath::kProxyRx);
LogInfo("Sent to commissioner on %s", UriPath::kProxyRx);
exit:
FreeMessageOnError(message, error);
@@ -412,7 +414,7 @@ void BorderAgent::HandleRelayReceive(const Coap::Message &aMessage)
}
SuccessOrExit(error = ForwardToCommissioner(*message, aMessage));
otLogInfoMeshCoP("Sent to commissioner on %s", UriPath::kRelayRx);
LogInfo("Sent to commissioner on %s", UriPath::kRelayRx);
exit:
FreeMessageOnError(message, error);
@@ -430,7 +432,7 @@ Error BorderAgent::ForwardToCommissioner(Coap::Message &aForwardMessage, const M
SuccessOrExit(error =
Get<Coap::CoapSecure>().SendMessage(aForwardMessage, Get<Coap::CoapSecure>().GetMessageInfo()));
otLogInfoMeshCoP("Sent to commissioner");
LogInfo("Sent to commissioner");
exit:
LogError("send to commissioner", error);
@@ -478,7 +480,7 @@ void BorderAgent::HandleRelayTransmit(const Coap::Message &aMessage)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("Sent to joiner router request on %s", UriPath::kRelayTx);
LogInfo("Sent to joiner router request on %s", UriPath::kRelayTx);
exit:
FreeMessageOnError(message, error);
@@ -531,7 +533,7 @@ Error BorderAgent::ForwardToLeader(const Coap::Message & aMessage,
// HandleCoapResponse is responsible to free this forward context.
forwardContext = nullptr;
otLogInfoMeshCoP("Forwarded request to leader on %s", aPath);
LogInfo("Forwarded request to leader on %s", aPath);
exit:
LogError("forward to leader", error);
@@ -559,13 +561,13 @@ void BorderAgent::HandleConnected(bool aConnected)
{
if (aConnected)
{
otLogInfoMeshCoP("Commissioner connected");
LogInfo("Commissioner connected");
mState = kStateActive;
mTimer.Start(kKeepAliveTimeout);
}
else
{
otLogInfoMeshCoP("Commissioner disconnected");
LogInfo("Commissioner disconnected");
IgnoreError(Get<Ip6::Udp>().RemoveReceiver(mUdpReceiver));
Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc);
mState = kStateStarted;
@@ -609,12 +611,12 @@ void BorderAgent::Start(void)
mState = kStateStarted;
mUdpProxyPort = 0;
otLogInfoMeshCoP("Border Agent start listening on port %d", kBorderAgentUdpPort);
LogInfo("Border Agent start listening on port %d", kBorderAgentUdpPort);
exit:
if (error != kErrorNone)
{
otLogWarnMeshCoP("failed to start Border Agent on port %d: %s", kBorderAgentUdpPort, ErrorToString(error));
LogWarn("failed to start Border Agent on port %d: %s", kBorderAgentUdpPort, ErrorToString(error));
}
}
@@ -628,7 +630,7 @@ void BorderAgent::HandleTimeout(void)
if (Get<Coap::CoapSecure>().IsConnected())
{
Get<Coap::CoapSecure>().Disconnect();
otLogWarnMeshCoP("Reset commissioner session");
LogWarn("Reset commissioner session");
}
}
@@ -658,7 +660,7 @@ void BorderAgent::Stop(void)
mState = kStateStopped;
mUdpProxyPort = 0;
otLogInfoMeshCoP("Border Agent stopped");
LogInfo("Border Agent stopped");
exit:
return;
+27 -26
View File
@@ -43,7 +43,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/string.hpp"
#include "meshcop/joiner.hpp"
#include "meshcop/joiner_router.hpp"
@@ -56,6 +56,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("Commissioner");
Commissioner::Commissioner(Instance &aInstance)
: InstanceLocator(aInstance)
, mActiveJoiner(nullptr)
@@ -96,7 +98,7 @@ void Commissioner::SetState(State aState)
SuccessOrExit(Get<Notifier>().Update(mState, aState, kEventCommissionerStateChanged));
otLogInfoMeshCoP("CommissionerState: %s -> %s", StateToString(oldState), StateToString(aState));
LogInfo("State: %s -> %s", StateToString(oldState), StateToString(aState));
if (mStateCallback)
{
@@ -641,7 +643,7 @@ void Commissioner::HandleJoinerExpirationTimer(void)
if (joiner.mExpirationTime <= now)
{
otLogDebgMeshCoP("removing joiner due to timeout or successfully joined");
LogDebg("removing joiner due to timeout or successfully joined");
RemoveJoinerEntry(joiner);
}
}
@@ -711,7 +713,7 @@ Error Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs, uint8_t
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo,
Commissioner::HandleMgmtCommissionerGetResponse, this));
otLogInfoMeshCoP("sent MGMT_COMMISSIONER_GET.req to leader");
LogInfo("sent MGMT_COMMISSIONER_GET.req to leader");
exit:
FreeMessageOnError(message, error);
@@ -734,7 +736,7 @@ void Commissioner::HandleMgmtCommissionerGetResponse(Coap::Message * aMe
OT_UNUSED_VARIABLE(aMessageInfo);
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged);
otLogInfoMeshCoP("received MGMT_COMMISSIONER_GET response");
LogInfo("received MGMT_COMMISSIONER_GET response");
exit:
return;
@@ -784,7 +786,7 @@ Error Commissioner::SendMgmtCommissionerSetRequest(const Dataset &aDataset, cons
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo,
Commissioner::HandleMgmtCommissionerSetResponse, this));
otLogInfoMeshCoP("sent MGMT_COMMISSIONER_SET.req to leader");
LogInfo("sent MGMT_COMMISSIONER_SET.req to leader");
exit:
FreeMessageOnError(message, error);
@@ -807,7 +809,7 @@ void Commissioner::HandleMgmtCommissionerSetResponse(Coap::Message * aMe
OT_UNUSED_VARIABLE(aMessageInfo);
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged);
otLogInfoMeshCoP("received MGMT_COMMISSIONER_SET response");
LogInfo("received MGMT_COMMISSIONER_SET response");
exit:
return;
@@ -838,7 +840,7 @@ Error Commissioner::SendPetition(void)
SuccessOrExit(
error = Get<Tmf::Agent>().SendMessage(*message, messageInfo, Commissioner::HandleLeaderPetitionResponse, this));
otLogInfoMeshCoP("sent petition");
LogInfo("sent petition");
exit:
FreeMessageOnError(message, error);
@@ -867,7 +869,7 @@ void Commissioner::HandleLeaderPetitionResponse(Coap::Message * aMessage
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged,
retransmit = (mState == kStatePetition));
otLogInfoMeshCoP("received Leader Petition response");
LogInfo("received Leader Petition response");
SuccessOrExit(Tlv::Find<StateTlv>(*aMessage, state));
VerifyOrExit(state == StateTlv::kAccept, IgnoreError(Stop(kDoNotSendKeepAlive)));
@@ -933,7 +935,7 @@ void Commissioner::SendKeepAlive(uint16_t aSessionId)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo,
Commissioner::HandleLeaderKeepAliveResponse, this));
otLogInfoMeshCoP("sent keep alive");
LogInfo("sent keep alive");
exit:
FreeMessageOnError(message, error);
@@ -961,7 +963,7 @@ void Commissioner::HandleLeaderKeepAliveResponse(Coap::Message * aMessag
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged,
IgnoreError(Stop(kDoNotSendKeepAlive)));
otLogInfoMeshCoP("received Leader keep-alive response");
LogInfo("received Leader keep-alive response");
SuccessOrExit(Tlv::Find<StateTlv>(*aMessage, state));
VerifyOrExit(state == StateTlv::kAccept, IgnoreError(Stop(kDoNotSendKeepAlive)));
@@ -1025,7 +1027,7 @@ void Commissioner::HandleRelayReceive(Coap::Message &aMessage, const Ip6::Messag
mJoinerPort = joinerPort;
mJoinerRloc = joinerRloc;
otLogInfoMeshCoP("Received Relay Receive (%s, 0x%04x)", mJoinerIid.ToString().AsCString(), mJoinerRloc);
LogInfo("Received Relay Receive (%s, 0x%04x)", mJoinerIid.ToString().AsCString(), mJoinerRloc);
aMessage.SetOffset(offset);
SuccessOrExit(error = aMessage.SetLength(offset + length));
@@ -1049,11 +1051,11 @@ void Commissioner::HandleDatasetChanged(Coap::Message &aMessage, const Ip6::Mess
{
VerifyOrExit(aMessage.IsConfirmablePostRequest());
otLogInfoMeshCoP("received dataset changed");
LogInfo("received dataset changed");
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
otLogInfoMeshCoP("sent dataset changed acknowledgment");
LogInfo("sent dataset changed acknowledgment");
exit:
return;
@@ -1071,7 +1073,7 @@ void Commissioner::HandleJoinerFinalize(Coap::Message &aMessage, const Ip6::Mess
StateTlv::State state = StateTlv::kAccept;
ProvisioningUrlTlv provisioningUrl;
otLogInfoMeshCoP("received joiner finalize");
LogInfo("received joiner finalize");
if (Tlv::FindTlv(aMessage, provisioningUrl) == kErrorNone)
{
@@ -1090,8 +1092,7 @@ void Commissioner::HandleJoinerFinalize(Coap::Message &aMessage, const Ip6::Mess
uint8_t buf[OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE];
aMessage.ReadBytes(aMessage.GetOffset(), buf, aMessage.GetLength() - aMessage.GetOffset());
otDumpCertMeshCoP("[THCI] direction=recv | type=JOIN_FIN.req |", buf,
aMessage.GetLength() - aMessage.GetOffset());
DumpCert("[THCI] direction=recv | type=JOIN_FIN.req |", buf, aMessage.GetLength() - aMessage.GetOffset());
}
#endif
@@ -1122,7 +1123,7 @@ void Commissioner::SendJoinFinalizeResponse(const Coap::Message &aRequest, State
VerifyOrExit(message->GetLength() <= sizeof(buf));
message->ReadBytes(message->GetOffset(), buf, message->GetLength() - message->GetOffset());
otDumpCertMeshCoP("[THCI] direction=send | type=JOIN_FIN.rsp |", buf, message->GetLength() - message->GetOffset());
DumpCert("[THCI] direction=send | type=JOIN_FIN.rsp |", buf, message->GetLength() - message->GetOffset());
#endif
SuccessOrExit(error = Get<Coap::CoapSecure>().SendMessage(*message, joinerMessageInfo));
@@ -1135,7 +1136,7 @@ void Commissioner::SendJoinFinalizeResponse(const Coap::Message &aRequest, State
RemoveJoiner(*mActiveJoiner, kRemoveJoinerDelay);
}
otLogInfoMeshCoP("sent joiner finalize response");
LogInfo("sent joiner finalize response");
exit:
FreeMessageOnError(message, error);
@@ -1209,7 +1210,7 @@ exit:
// LCOV_EXCL_START
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MESHCOP == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
const char *Commissioner::StateToString(State aState)
{
@@ -1234,17 +1235,17 @@ void Commissioner::LogJoinerEntry(const char *aAction, const Joiner &aJoiner) co
break;
case Joiner::kTypeAny:
otLogInfoMeshCoP("%s Joiner (any, %s)", aAction, aJoiner.mPskd.GetAsCString());
LogInfo("%s Joiner (any, %s)", aAction, aJoiner.mPskd.GetAsCString());
break;
case Joiner::kTypeEui64:
otLogInfoMeshCoP("%s Joiner (eui64:%s, %s)", aAction, aJoiner.mSharedId.mEui64.ToString().AsCString(),
aJoiner.mPskd.GetAsCString());
LogInfo("%s Joiner (eui64:%s, %s)", aAction, aJoiner.mSharedId.mEui64.ToString().AsCString(),
aJoiner.mPskd.GetAsCString());
break;
case Joiner::kTypeDiscerner:
otLogInfoMeshCoP("%s Joiner (disc:%s, %s)", aAction, aJoiner.mSharedId.mDiscerner.ToString().AsCString(),
aJoiner.mPskd.GetAsCString());
LogInfo("%s Joiner (disc:%s, %s)", aAction, aJoiner.mSharedId.mDiscerner.ToString().AsCString(),
aJoiner.mPskd.GetAsCString());
break;
}
}
@@ -1255,7 +1256,7 @@ void Commissioner::LogJoinerEntry(const char *, const Joiner &) const
{
}
#endif // (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_MESHCOP == 1)
#endif // OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
// LCOV_EXCL_STOP
+4 -3
View File
@@ -40,7 +40,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "mac/mac_types.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/mle_tlvs.hpp"
@@ -48,6 +48,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("Dataset");
Error Dataset::Info::GenerateRandom(Instance &aInstance)
{
Error error;
@@ -539,8 +541,7 @@ Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdate
if (error != kErrorNone)
{
otLogWarnMeshCoP("DatasetManager::ApplyConfiguration() Failed to set channel to %d (%s)", channel,
ErrorToString(error));
LogWarn("ApplyConfiguration() Failed to set channel to %d (%s)", channel, ErrorToString(error));
ExitNow();
}
+5 -3
View File
@@ -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 "crypto/storage.hpp"
#include "meshcop/dataset.hpp"
@@ -49,6 +49,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("DatasetLocal");
DatasetLocal::DatasetLocal(Instance &aInstance, Dataset::Type aType)
: InstanceLocator(aInstance)
, mUpdateTime(0)
@@ -189,7 +191,7 @@ Error DatasetLocal::Save(const Dataset &aDataset)
// do not propagate error back
IgnoreError(Get<Settings>().DeleteOperationalDataset(IsActive()));
mSaved = false;
otLogInfoMeshCoP("%s dataset deleted", Dataset::TypeToString(mType));
LogInfo("%s dataset deleted", Dataset::TypeToString(mType));
}
else
{
@@ -205,7 +207,7 @@ Error DatasetLocal::Save(const Dataset &aDataset)
#endif
mSaved = true;
otLogInfoMeshCoP("%s dataset set", Dataset::TypeToString(mType));
LogInfo("%s dataset set", Dataset::TypeToString(mType));
}
mTimestampPresent = (aDataset.GetTimestamp(mType, mTimestamp) == kErrorNone);
+11 -9
View File
@@ -39,7 +39,7 @@
#include "common/as_core_type.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/notifier.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
@@ -51,6 +51,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("DatasetManager");
DatasetManager::DatasetManager(Instance &aInstance, Dataset::Type aType, Timer::Handler aTimerHandler)
: InstanceLocator(aInstance)
, mLocal(aInstance, aType)
@@ -291,7 +293,7 @@ void DatasetManager::SendSet(void)
SuccessOrExit(
error = Get<Tmf::Agent>().SendMessage(*message, messageInfo, &DatasetManager::HandleMgmtSetResponse, this));
otLogInfoMeshCoP("Sent %s set to leader", Dataset::TypeToString(GetType()));
LogInfo("Sent %s set to leader", Dataset::TypeToString(GetType()));
exit:
@@ -345,7 +347,7 @@ void DatasetManager::HandleMgmtSetResponse(Coap::Message *aMessage, const Ip6::M
}
exit:
otLogInfoMeshCoP("MGMT_SET finished: %s", ErrorToString(error));
LogInfo("MGMT_SET finished: %s", ErrorToString(error));
mMgmtPending = false;
@@ -454,8 +456,8 @@ void DatasetManager::SendGetResponse(const Coap::Message & aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
otLogInfoMeshCoP("sent %s dataset get response to %s", (GetType() == Dataset::kActive ? "active" : "pending"),
aMessageInfo.GetPeerAddr().ToString().AsCString());
LogInfo("sent %s dataset get response to %s", (GetType() == Dataset::kActive ? "active" : "pending"),
aMessageInfo.GetPeerAddr().ToString().AsCString());
exit:
FreeMessageOnError(message, error);
@@ -533,7 +535,7 @@ Error DatasetManager::SendSetRequest(const Dataset::Info & aDatasetInfo,
mMgmtSetCallbackContext = aContext;
mMgmtPending = true;
otLogInfoMeshCoP("sent dataset set request to leader");
LogInfo("sent dataset set request to leader");
exit:
FreeMessageOnError(message, error);
@@ -654,7 +656,7 @@ Error DatasetManager::SendGetRequest(const Dataset::Components &aDatasetComponen
messageInfo.SetPeerPort(Tmf::kUdpPort);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent dataset get request");
LogInfo("sent dataset get request");
exit:
FreeMessageOnError(message, error);
@@ -811,7 +813,7 @@ void PendingDataset::StartDelayTimer(void)
}
mDelayTimer.StartAt(dataset.GetUpdateTime(), delay);
otLogInfoMeshCoP("delay timer started %d", delay);
LogInfo("delay timer started %d", delay);
}
}
@@ -841,7 +843,7 @@ void PendingDataset::HandleDelayTimer(void)
}
}
otLogInfoMeshCoP("pending delay timer expired");
LogInfo("pending delay timer expired");
dataset.ConvertToActive();
+5 -3
View File
@@ -46,7 +46,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "common/timer.hpp"
#include "meshcop/dataset.hpp"
@@ -60,6 +60,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("DatasetManager");
Error DatasetManager::AppendMleDatasetTlv(Message &aMessage) const
{
Dataset dataset;
@@ -277,7 +279,7 @@ void DatasetManager::SendSetResponse(const Coap::Message & aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
otLogInfoMeshCoP("sent dataset set response");
LogInfo("sent dataset set response");
exit:
FreeMessageOnError(message, error);
@@ -388,7 +390,7 @@ Error ActiveDataset::GenerateLocal(void)
SuccessOrExit(error = mLocal.Save(dataset));
IgnoreError(Restore());
otLogInfoMeshCoP("Generated local dataset");
LogInfo("Generated local dataset");
exit:
return error;
+1 -1
View File
@@ -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/random.hpp"
namespace ot {
+21 -19
View File
@@ -46,7 +46,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/timer.hpp"
#include "crypto/mbedtls.hpp"
#include "crypto/sha256.hpp"
@@ -57,6 +57,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("Dtls");
const mbedtls_ecp_group_id Dtls::sCurves[] = {MBEDTLS_ECP_DP_SECP256R1, MBEDTLS_ECP_DP_NONE};
#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) || defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
const int Dtls::sHashes[] = {MBEDTLS_MD_SHA256, MBEDTLS_MD_NONE};
@@ -338,12 +340,12 @@ Error Dtls::Setup(bool aClient)
if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8)
{
otLogInfoMeshCoP("DTLS started");
LogInfo("DTLS started");
}
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
else
{
otLogInfoCoap("Application Coap Secure DTLS started");
LogInfo("Application Coap Secure DTLS started");
}
#endif
@@ -408,7 +410,7 @@ int Dtls::SetApplicationCoapSecureKeys(void)
break;
default:
otLogCritCoap("Application Coap Secure DTLS: Not supported cipher.");
LogCrit("Application Coap Secure: Not supported cipher.");
rval = MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
ExitNow();
break;
@@ -590,12 +592,12 @@ int Dtls::HandleMbedtlsTransmit(const unsigned char *aBuf, size_t aLength)
if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8)
{
otLogDebgMeshCoP("Dtls::HandleMbedtlsTransmit");
LogDebg("HandleMbedtlsTransmit");
}
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
else
{
otLogDebgCoap("Dtls::ApplicationCoapSecure HandleMbedtlsTransmit");
LogDebg("ApplicationCoapSecure HandleMbedtlsTransmit");
}
#endif
@@ -615,7 +617,7 @@ int Dtls::HandleMbedtlsTransmit(const unsigned char *aBuf, size_t aLength)
break;
default:
otLogWarnMeshCoP("Dtls::HandleMbedtlsTransmit: %s error", ErrorToString(error));
LogWarn("HandleMbedtlsTransmit: %s error", ErrorToString(error));
rval = MBEDTLS_ERR_NET_SEND_FAILED;
break;
}
@@ -634,12 +636,12 @@ int Dtls::HandleMbedtlsReceive(unsigned char *aBuf, size_t aLength)
if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8)
{
otLogDebgMeshCoP("Dtls::HandleMbedtlsReceive");
LogDebg("HandleMbedtlsReceive");
}
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
else
{
otLogDebgCoap("Dtls:: ApplicationCoapSecure HandleMbedtlsReceive");
LogDebg("ApplicationCoapSecure HandleMbedtlsReceive");
}
#endif
@@ -669,12 +671,12 @@ int Dtls::HandleMbedtlsGetTimer(void)
if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8)
{
otLogDebgMeshCoP("Dtls::HandleMbedtlsGetTimer");
LogDebg("HandleMbedtlsGetTimer");
}
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
else
{
otLogDebgCoap("Dtls:: ApplicationCoapSecure HandleMbedtlsGetTimer");
LogDebg("ApplicationCoapSecure HandleMbedtlsGetTimer");
}
#endif
@@ -707,12 +709,12 @@ void Dtls::HandleMbedtlsSetTimer(uint32_t aIntermediate, uint32_t aFinish)
{
if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8)
{
otLogDebgMeshCoP("Dtls::SetTimer");
LogDebg("SetTimer");
}
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
else
{
otLogDebgCoap("Dtls::ApplicationCoapSecure SetTimer");
LogDebg("ApplicationCoapSecure SetTimer");
}
#endif
@@ -769,7 +771,7 @@ void Dtls::HandleMbedtlsExportKeys(mbedtls_ssl_key_export_type aType,
sha256.Update(keyBlock, kDtlsKeyBlockSize);
sha256.Finish(kek);
otLogDebgMeshCoP("Generated KEK");
LogDebg("Generated KEK");
Get<KeyManager>().SetKek(kek.GetBytes());
exit:
@@ -806,7 +808,7 @@ int Dtls::HandleMbedtlsExportKeys(const unsigned char *aMasterSecret,
sha256.Update(aKeyBlock, 2 * static_cast<uint16_t>(aMacLength + aKeyLength + aIvLength));
sha256.Finish(kek);
otLogDebgMeshCoP("Generated KEK");
LogDebg("Generated KEK");
Get<KeyManager>().SetKek(kek.GetBytes());
exit:
@@ -952,20 +954,20 @@ void Dtls::HandleMbedtlsDebug(int aLevel, const char *aFile, int aLine, const ch
switch (aLevel)
{
case 1:
otLogCritMbedTls("[%hu] %s", mSocket.GetSockName().mPort, aStr);
LogCrit("[%hu] %s", mSocket.GetSockName().mPort, aStr);
break;
case 2:
otLogWarnMbedTls("[%hu] %s", mSocket.GetSockName().mPort, aStr);
LogWarn("[%hu] %s", mSocket.GetSockName().mPort, aStr);
break;
case 3:
otLogInfoMbedTls("[%hu] %s", mSocket.GetSockName().mPort, aStr);
LogInfo("[%hu] %s", mSocket.GetSockName().mPort, aStr);
break;
case 4:
default:
otLogDebgMbedTls("[%hu] %s", mSocket.GetSockName().mPort, aStr);
LogDebg("[%hu] %s", mSocket.GetSockName().mPort, aStr);
break;
}
}
+6 -4
View File
@@ -42,7 +42,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/thread_netif.hpp"
@@ -50,6 +50,8 @@
namespace ot {
RegisterLogModule("EnergyScanClnt");
EnergyScanClient::EnergyScanClient(Instance &aInstance)
: InstanceLocator(aInstance)
, mCallback(nullptr)
@@ -94,7 +96,7 @@ Error EnergyScanClient::SendQuery(uint32_t aChannelMas
messageInfo.SetPeerPort(Tmf::kUdpPort);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent energy scan query");
LogInfo("sent query");
mCallback = aCallback;
mContext = aContext;
@@ -122,7 +124,7 @@ void EnergyScanClient::HandleReport(Coap::Message &aMessage, const Ip6::MessageI
VerifyOrExit(aMessage.IsConfirmablePostRequest());
otLogInfoMeshCoP("received energy scan report");
LogInfo("received report");
VerifyOrExit((mask = MeshCoP::ChannelMaskTlv::GetChannelMask(aMessage)) != 0);
@@ -136,7 +138,7 @@ void EnergyScanClient::HandleReport(Coap::Message &aMessage, const Ip6::MessageI
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
otLogInfoMeshCoP("sent energy scan report response");
LogInfo("sent report response");
exit:
return;
+21 -17
View File
@@ -44,7 +44,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/string.hpp"
#include "meshcop/meshcop.hpp"
#include "radio/radio.hpp"
@@ -55,6 +55,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("Joiner");
Joiner::Joiner(Instance &aInstance)
: InstanceLocator(aInstance)
, mId()
@@ -121,7 +123,7 @@ void Joiner::SetState(State aState)
SuccessOrExit(Get<Notifier>().Update(mState, aState, kEventJoinerStateChanged));
otLogInfoMeshCoP("JoinerState: %s -> %s", StateToString(oldState), StateToString(aState));
LogInfo("JoinerState: %s -> %s", StateToString(oldState), StateToString(aState));
exit:
return;
}
@@ -140,7 +142,7 @@ Error Joiner::Start(const char * aPskd,
Mac::ExtAddress randomAddress;
SteeringData::HashBitIndexes filterIndexes;
otLogInfoMeshCoP("Joiner starting");
LogInfo("Joiner starting");
VerifyOrExit(aProvisioningUrl == nullptr || IsValidUtf8String(aProvisioningUrl), error = kErrorInvalidArgs);
VerifyOrExit(aVendorName == nullptr || IsValidUtf8String(aVendorName), error = kErrorInvalidArgs);
@@ -197,7 +199,7 @@ exit:
void Joiner::Stop(void)
{
otLogInfoMeshCoP("Joiner stopped");
LogInfo("Joiner stopped");
// Callback is set to `nullptr` to skip calling it from `Finish()`
mCallback = nullptr;
@@ -308,9 +310,9 @@ void Joiner::SaveDiscoveredJoinerRouter(const Mle::DiscoverScanner::ScanResult &
doesAllowAny = AsCoreType(&aResult.mSteeringData).PermitsAllJoiners();
otLogInfoMeshCoP("Joiner discover network: %s, pan:0x%04x, port:%d, chan:%d, rssi:%d, allow-any:%s",
AsCoreType(&aResult.mExtAddress).ToString().AsCString(), aResult.mPanId, aResult.mJoinerUdpPort,
aResult.mChannel, aResult.mRssi, ToYesNo(doesAllowAny));
LogInfo("Joiner discover network: %s, pan:0x%04x, port:%d, chan:%d, rssi:%d, allow-any:%s",
AsCoreType(&aResult.mExtAddress).ToString().AsCString(), aResult.mPanId, aResult.mJoinerUdpPort,
aResult.mChannel, aResult.mRssi, ToYesNo(doesAllowAny));
priority = CalculatePriority(aResult.mRssi, doesAllowAny);
@@ -385,8 +387,8 @@ Error Joiner::Connect(JoinerRouter &aRouter)
Error error = kErrorNotFound;
Ip6::SockAddr sockAddr(aRouter.mJoinerUdpPort);
otLogInfoMeshCoP("Joiner connecting to %s, pan:0x%04x, chan:%d", aRouter.mExtAddr.ToString().AsCString(),
aRouter.mPanId, aRouter.mChannel);
LogInfo("Joiner connecting to %s, pan:0x%04x, chan:%d", aRouter.mExtAddr.ToString().AsCString(), aRouter.mPanId,
aRouter.mChannel);
Get<Mac::Mac>().SetPanId(aRouter.mPanId);
SuccessOrExit(error = Get<Mac::Mac>().SetPanChannel(aRouter.mChannel));
@@ -515,7 +517,7 @@ void Joiner::SendJoinerFinalize(void)
SuccessOrExit(Get<Coap::CoapSecure>().SendMessage(*mFinalizeMessage, Joiner::HandleJoinerFinalizeResponse, this));
mFinalizeMessage = nullptr;
otLogInfoMeshCoP("Joiner sent finalize");
LogInfo("Joiner sent finalize");
exit:
return;
@@ -546,7 +548,7 @@ void Joiner::HandleJoinerFinalizeResponse(Coap::Message *aMessage, const Ip6::Me
SetState(kStateEntrust);
mTimer.Start(kReponseTimeout);
otLogInfoMeshCoP("Joiner received finalize response %d", state);
LogInfo("Joiner received finalize response %d", state);
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
LogCertMessage("[THCI] direction=recv | type=JOIN_FIN.rsp |", *aMessage);
@@ -569,8 +571,8 @@ void Joiner::HandleJoinerEntrust(Coap::Message &aMessage, const Ip6::MessageInfo
VerifyOrExit(mState == kStateEntrust && aMessage.IsConfirmablePostRequest(), error = kErrorDrop);
otLogInfoMeshCoP("Joiner received entrust");
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_ENT.ntf");
LogInfo("Joiner received entrust");
LogCert("[THCI] direction=recv | type=JOIN_ENT.ntf");
datasetInfo.Clear();
@@ -581,7 +583,7 @@ void Joiner::HandleJoinerEntrust(Coap::Message &aMessage, const Ip6::MessageInfo
IgnoreError(Get<MeshCoP::ActiveDataset>().Save(datasetInfo));
otLogInfoMeshCoP("Joiner successful!");
LogInfo("Joiner successful!");
SendJoinerEntrustResponse(aMessage, aMessageInfo);
@@ -607,8 +609,8 @@ void Joiner::SendJoinerEntrustResponse(const Coap::Message &aRequest, const Ip6:
SetState(kStateJoined);
otLogInfoMeshCoP("Joiner sent entrust response");
otLogCertMeshCoP("[THCI] direction=send | type=JOIN_ENT.rsp");
LogInfo("Joiner sent entrust response");
LogCert("[THCI] direction=send | type=JOIN_ENT.rsp");
exit:
FreeMessageOnError(message, error);
@@ -676,12 +678,14 @@ const char *Joiner::StateToString(State aState)
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
void Joiner::LogCertMessage(const char *aText, const Coap::Message &aMessage) const
{
OT_UNUSED_VARIABLE(aText);
uint8_t buf[OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE];
VerifyOrExit(aMessage.GetLength() <= sizeof(buf));
aMessage.ReadBytes(aMessage.GetOffset(), buf, aMessage.GetLength() - aMessage.GetOffset());
otDumpCertMeshCoP(aText, buf, aMessage.GetLength() - aMessage.GetOffset());
DumpCert(aText, buf, aMessage.GetLength() - aMessage.GetOffset());
exit:
return;
+1 -1
View File
@@ -45,7 +45,7 @@
#include "coap/coap_secure.hpp"
#include "common/as_core_type.hpp"
#include "common/locator.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/message.hpp"
#include "common/non_copyable.hpp"
#include "mac/mac_types.hpp"
+13 -11
View File
@@ -42,7 +42,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/mle.hpp"
@@ -52,6 +52,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("JoinerRouter");
JoinerRouter::JoinerRouter(Instance &aInstance)
: InstanceLocator(aInstance)
, mSocket(aInstance)
@@ -84,7 +86,7 @@ void JoinerRouter::Start(void)
IgnoreError(mSocket.Open(&JoinerRouter::HandleUdpReceive, this));
IgnoreError(mSocket.Bind(port));
IgnoreError(Get<Ip6::Filter>().AddUnsecurePort(port));
otLogInfoMeshCoP("Joiner Router: start");
LogInfo("Joiner Router: start");
}
else
{
@@ -136,7 +138,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
uint16_t borderAgentRloc;
uint16_t offset;
otLogInfoMeshCoP("JoinerRouter::HandleUdpReceive");
LogInfo("JoinerRouter::HandleUdpReceive");
SuccessOrExit(error = GetBorderAgentRloc(Get<ThreadNetif>(), borderAgentRloc));
@@ -163,7 +165,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("Sent relay rx");
LogInfo("Sent relay rx");
exit:
FreeMessageOnError(message, error);
@@ -190,7 +192,7 @@ void JoinerRouter::HandleRelayTransmit(Coap::Message &aMessage, const Ip6::Messa
VerifyOrExit(aMessage.IsNonConfirmablePostRequest(), error = kErrorDrop);
otLogInfoMeshCoP("Received relay transmit");
LogInfo("Received relay transmit");
SuccessOrExit(error = Tlv::Find<JoinerUdpPortTlv>(aMessage, joinerPort));
SuccessOrExit(error = Tlv::Find<JoinerIidTlv>(aMessage, joinerIid));
@@ -209,7 +211,7 @@ void JoinerRouter::HandleRelayTransmit(Coap::Message &aMessage, const Ip6::Messa
if (Tlv::Find<JoinerRouterKekTlv>(aMessage, kek) == kErrorNone)
{
otLogInfoMeshCoP("Received kek");
LogInfo("Received kek");
DelaySendingJoinerEntrust(messageInfo, kek);
}
@@ -295,12 +297,12 @@ Error JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo)
IgnoreError(Get<Tmf::Agent>().AbortTransaction(&JoinerRouter::HandleJoinerEntrustResponse, this));
otLogInfoMeshCoP("Sending JOIN_ENT.ntf");
LogInfo("Sending JOIN_ENT.ntf");
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo,
&JoinerRouter::HandleJoinerEntrustResponse, this));
otLogInfoMeshCoP("Sent joiner entrust length = %d", message->GetLength());
otLogCertMeshCoP("[THCI] direction=send | type=JOIN_ENT.ntf");
LogInfo("Sent joiner entrust length = %d", message->GetLength());
LogCert("[THCI] direction=send | type=JOIN_ENT.ntf");
exit:
FreeMessageOnError(message, error);
@@ -406,8 +408,8 @@ void JoinerRouter::HandleJoinerEntrustResponse(Coap::Message * aMessage,
VerifyOrExit(aMessage->GetCode() == Coap::kCodeChanged);
otLogInfoMeshCoP("Receive joiner entrust response");
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_ENT.rsp");
LogInfo("Receive joiner entrust response");
LogCert("[THCI] direction=recv | type=JOIN_ENT.rsp");
exit:
return;
+6 -3
View File
@@ -36,7 +36,7 @@
#include "common/crc16.hpp"
#include "common/debug.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/string.hpp"
#include "crypto/pbkdf2_cmac.hpp"
#include "crypto/sha256.hpp"
@@ -44,6 +44,9 @@
#include "thread/thread_netif.hpp"
namespace ot {
RegisterLogModule("MeshCoP");
namespace MeshCoP {
Error JoinerPskd::SetFrom(const char *aPskdString)
@@ -354,12 +357,12 @@ exit:
}
#endif // OPENTHREAD_FTD
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN) && (OPENTHREAD_CONFIG_LOG_MESHCOP == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
void LogError(const char *aActionText, Error aError)
{
if (aError != kErrorNone)
{
otLogWarnMeshCoP("Failed to %s: %s", aActionText, ErrorToString(aError));
LogWarn("Failed to %s: %s", aActionText, ErrorToString(aError));
}
}
#endif
+1 -1
View File
@@ -445,7 +445,7 @@ void ComputeJoinerId(const Mac::ExtAddress &aEui64, Mac::ExtAddress &aJoinerId);
*/
Error GetBorderAgentRloc(ThreadNetif &aNetIf, uint16_t &aRloc);
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN) && (OPENTHREAD_CONFIG_LOG_MESHCOP == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
/**
* This function emits a log message indicating an error during a MeshCoP action.
*
+9 -7
View File
@@ -42,7 +42,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/random.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
@@ -53,6 +53,8 @@
namespace ot {
namespace MeshCoP {
RegisterLogModule("MeshCoPLeader");
Leader::Leader(Instance &aInstance)
: InstanceLocator(aInstance)
, mPetition(UriPath::kLeaderPetition, Leader::HandlePetition, this)
@@ -78,7 +80,7 @@ void Leader::HandlePetition(Coap::Message &aMessage, const Ip6::MessageInfo &aMe
CommissionerIdTlv commissionerId;
StateTlv::State state = StateTlv::kReject;
otLogInfoMeshCoP("received petition");
LogInfo("received petition");
VerifyOrExit(Get<Mle::MleRouter>().IsRoutingLocator(aMessageInfo.GetPeerAddr()));
SuccessOrExit(Tlv::FindTlv(aMessage, commissionerId));
@@ -145,7 +147,7 @@ void Leader::SendPetitionResponse(const Coap::Message & aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
otLogInfoMeshCoP("sent petition response");
LogInfo("sent petition response");
exit:
FreeMessageOnError(message, error);
@@ -164,7 +166,7 @@ void Leader::HandleKeepAlive(Coap::Message &aMessage, const Ip6::MessageInfo &aM
BorderAgentLocatorTlv *borderAgentLocator;
StateTlv::State responseState;
otLogInfoMeshCoP("received keep alive");
LogInfo("received keep alive");
SuccessOrExit(Tlv::Find<StateTlv>(aMessage, state));
@@ -218,7 +220,7 @@ void Leader::SendKeepAliveResponse(const Coap::Message & aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
otLogInfoMeshCoP("sent keep alive response");
LogInfo("sent keep alive response");
exit:
FreeMessageOnError(message, error);
@@ -240,7 +242,7 @@ void Leader::SendDatasetChanged(const Ip6::Address &aAddress)
messageInfo.SetPeerPort(Tmf::kUdpPort);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent dataset changed");
LogInfo("sent dataset changed");
exit:
FreeMessageOnError(message, error);
@@ -294,7 +296,7 @@ void Leader::ResignCommissioner(void)
mTimer.Stop();
SetEmptyCommissionerData();
otLogInfoMeshCoP("commissioner inactive");
LogInfo("commissioner inactive");
}
} // namespace MeshCoP
+6 -4
View File
@@ -41,7 +41,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/thread_netif.hpp"
@@ -49,6 +49,8 @@
namespace ot {
RegisterLogModule("PanIdQueryClnt");
PanIdQueryClient::PanIdQueryClient(Instance &aInstance)
: InstanceLocator(aInstance)
, mCallback(nullptr)
@@ -89,7 +91,7 @@ Error PanIdQueryClient::SendQuery(uint16_t aPanId,
messageInfo.SetPeerPort(Tmf::kUdpPort);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent panid query");
LogInfo("sent panid query");
mCallback = aCallback;
mContext = aContext;
@@ -112,7 +114,7 @@ void PanIdQueryClient::HandleConflict(Coap::Message &aMessage, const Ip6::Messag
VerifyOrExit(aMessage.IsConfirmablePostRequest());
otLogInfoMeshCoP("received panid conflict");
LogInfo("received panid conflict");
SuccessOrExit(Tlv::Find<MeshCoP::PanIdTlv>(aMessage, panId));
@@ -125,7 +127,7 @@ void PanIdQueryClient::HandleConflict(Coap::Message &aMessage, const Ip6::Messag
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, responseInfo));
otLogInfoMeshCoP("sent panid query conflict response");
LogInfo("sent panid query conflict response");
exit:
return;
+6 -4
View File
@@ -40,7 +40,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "mac/mac.hpp"
#include "net/dhcp6.hpp"
#include "thread/thread_netif.hpp"
@@ -48,6 +48,8 @@
namespace ot {
namespace Dhcp6 {
RegisterLogModule("Dhcp6Client");
Client::Client(Instance &aInstance)
: InstanceLocator(aInstance)
, mSocket(aInstance)
@@ -146,7 +148,7 @@ void Client::UpdateAddresses(void)
}
else
{
otLogWarnIp6("Insufficient memory for new DHCP prefix");
LogWarn("Insufficient memory for new DHCP prefix");
continue;
}
}
@@ -283,13 +285,13 @@ void Client::Solicit(uint16_t aRloc16)
messageInfo.mPeerPort = kDhcpServerPort;
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
otLogInfoIp6("solicit");
LogInfo("solicit");
exit:
if (error != kErrorNone)
{
FreeMessage(message);
otLogWarnIp6("Failed to send DHCPv6 Solicit: %s", ErrorToString(error));
LogWarn("Failed to send DHCPv6 Solicit: %s", ErrorToString(error));
}
}
+4 -2
View File
@@ -41,13 +41,15 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "thread/mle.hpp"
#include "thread/thread_netif.hpp"
namespace ot {
namespace Dhcp6 {
RegisterLogModule("Dhcp6Server");
Server::Server(Instance &aInstance)
: InstanceLocator(aInstance)
, mSocket(aInstance)
@@ -176,7 +178,7 @@ exit:
if (error != kErrorNone)
{
otLogNoteIp6("Failed to add DHCPv6 prefix agent: %s", ErrorToString(error));
LogNote("Failed to add DHCPv6 prefix agent: %s", ErrorToString(error));
}
}
+4 -2
View File
@@ -36,7 +36,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "net/udp6.hpp"
#include "thread/network_data_types.hpp"
#include "thread/thread_netif.hpp"
@@ -49,6 +49,8 @@
namespace ot {
namespace Dns {
RegisterLogModule("DnsClient");
//---------------------------------------------------------------------------------------------------------------------
// Client::QueryConfig
@@ -1050,7 +1052,7 @@ Error Client::ParseResponse(Response &aResponse, QueryType &aType, Error &aRespo
exit:
if (error != kErrorNone)
{
otLogInfoDns("Failed to parse response %s", ErrorToString(error));
LogInfo("Failed to parse response %s", ErrorToString(error));
}
return error;
+17 -17
View File
@@ -36,7 +36,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
/**
@@ -47,6 +47,8 @@
namespace ot {
namespace Dns {
RegisterLogModule("DnsDso");
//---------------------------------------------------------------------------------------------------------------------
// otPlatDso transport callbacks
@@ -111,8 +113,8 @@ void Dso::Connection::SetState(State aState)
{
VerifyOrExit(mState != aState);
otLogInfoDns("[dso] State: %s -> %s on connection with %s", StateToString(mState), StateToString(aState),
mPeerSockAddr.ToString().AsCString());
LogInfo("State: %s -> %s on connection with %s", StateToString(mState), StateToString(aState),
mPeerSockAddr.ToString().AsCString());
mState = aState;
mStateDidChange = true;
@@ -254,7 +256,7 @@ void Dso::Connection::MarkAsDisconnected(void)
mPendingRequests.Clear();
SetState(kStateDisconnected);
otLogInfoDns("[dso] Disconnect reason: %s", DisconnectReasonToString(mDisconnectReason));
LogInfo("Disconnect reason: %s", DisconnectReasonToString(mDisconnectReason));
}
void Dso::Connection::MarkSessionEstablished(void)
@@ -297,7 +299,7 @@ void Dso::Connection::SetLongLivedOperation(bool aLongLivedOperation)
mLongLivedOperation = aLongLivedOperation;
otLogInfoDns("[dso] Long-lived operation %s", mLongLivedOperation ? "started" : "stopped");
LogInfo("Long-lived operation %s", mLongLivedOperation ? "started" : "stopped");
if (!mLongLivedOperation)
{
@@ -579,8 +581,8 @@ Error Dso::Connection::SendMessage(Message & aMessage,
}
}
otLogInfoDns("[dso] Sending %s message with id %u to %s", MessageTypeToString(aMessageType), aMessageId,
mPeerSockAddr.ToString().AsCString());
LogInfo("Sending %s message with id %u to %s", MessageTypeToString(aMessageType), aMessageId,
mPeerSockAddr.ToString().AsCString());
switch (mState)
{
@@ -817,7 +819,7 @@ Error Dso::Connection::ProcessRequestOrUnidirectionalMessage(const Dns::Header &
default:
if (aHeader.GetMessageId() == 0)
{
otLogInfoDns("[dso] Received unidirectional message from %s", mPeerSockAddr.ToString().AsCString());
LogInfo("Received unidirectional message from %s", mPeerSockAddr.ToString().AsCString());
error = mCallbacks.mProcessUnidirectionalMessage(*this, aMessage, aPrimaryTlvType);
}
@@ -825,8 +827,7 @@ Error Dso::Connection::ProcessRequestOrUnidirectionalMessage(const Dns::Header &
{
MessageId messageId = aHeader.GetMessageId();
otLogInfoDns("[dso] Received request message with id %u from %s", messageId,
mPeerSockAddr.ToString().AsCString());
LogInfo("Received request message with id %u from %s", messageId, mPeerSockAddr.ToString().AsCString());
error = mCallbacks.mProcessRequestMessage(*this, messageId, aMessage, aPrimaryTlvType);
@@ -956,8 +957,7 @@ Error Dso::Connection::ProcessKeepAliveMessage(const Dns::Header &aHeader, const
VerifyOrExit(aHeader.GetMessageId() != 0);
otLogInfoDns("[dso] Received KeepAlive request message from client %s",
mPeerSockAddr.ToString().AsCString());
LogInfo("Received KeepAlive request message from client %s", mPeerSockAddr.ToString().AsCString());
IgnoreError(SendKeepAliveMessage(kResponseMessage, aHeader.GetMessageId()));
error = kErrorNone;
@@ -971,8 +971,8 @@ Error Dso::Connection::ProcessKeepAliveMessage(const Dns::Header &aHeader, const
VerifyOrExit(aHeader.GetMessageId() == 0);
}
otLogInfoDns("[dso] Received Keep Alive %s message from server %s",
(aHeader.GetMessageId() == 0) ? "unidirectional" : "response", mPeerSockAddr.ToString().AsCString());
LogInfo("Received Keep Alive %s message from server %s",
(aHeader.GetMessageId() == 0) ? "unidirectional" : "response", mPeerSockAddr.ToString().AsCString());
// Receiving a Keep Alive interval value from server less than the
// minimum (ten seconds) is a fatal error and client MUST then
@@ -990,7 +990,7 @@ Error Dso::Connection::ProcessKeepAliveMessage(const Dns::Header &aHeader, const
AdjustInactivityTimeout(keepAliveTlv.GetInactivityTimeout());
mKeepAlive.SetInterval(keepAliveTlv.GetKeepAliveInterval());
otLogInfoDns("[dso] Timeouts Inactivity:%u, KeepAlive:%u", mInactivity.GetInterval(), mKeepAlive.GetInterval());
LogInfo("Timeouts Inactivity:%u, KeepAlive:%u", mInactivity.GetInterval(), mKeepAlive.GetInterval());
error = kErrorNone;
@@ -1018,8 +1018,8 @@ Error Dso::Connection::ProcessRetryDelayMessage(const Dns::Header &aHeader, cons
mRetryDelayErrorCode = aHeader.GetResponseCode();
mRetryDelay = retryDelayTlv.GetRetryDelay();
otLogInfoDns("[dso] Received Retry Delay message from server %s", mPeerSockAddr.ToString().AsCString());
otLogInfoDns("[dso] RetryDelay:%u ms, ResponseCode:%d", mRetryDelay, mRetryDelayErrorCode);
LogInfo("Received Retry Delay message from server %s", mPeerSockAddr.ToString().AsCString());
LogInfo(" RetryDelay:%u ms, ResponseCode:%d", mRetryDelay, mRetryDelayErrorCode);
Disconnect(kGracefullyClose, kReasonServerRetryDelayRequest);
-1
View File
@@ -36,7 +36,6 @@
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/logging.hpp"
#include "common/random.hpp"
#include "common/string.hpp"
+12 -10
View File
@@ -41,7 +41,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/string.hpp"
#include "net/srp_server.hpp"
#include "net/udp6.hpp"
@@ -50,6 +50,8 @@ namespace ot {
namespace Dns {
namespace ServiceDiscovery {
RegisterLogModule("DnssdServer");
const char Server::kDnssdProtocolUdp[] = "_udp";
const char Server::kDnssdProtocolTcp[] = "_tcp";
const char Server::kDnssdSubTypeLabel[] = "._sub.";
@@ -79,7 +81,7 @@ Error Server::Start(void)
#endif
exit:
otLogInfoDns("[server] started: %s", ErrorToString(error));
LogInfo("started: %s", ErrorToString(error));
if (error != kErrorNone)
{
@@ -103,7 +105,7 @@ void Server::Stop(void)
mTimer.Stop();
IgnoreError(mSocket.Close());
otLogInfoDns("[server] stopped");
LogInfo("stopped");
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
Get<Srp::Server>().HandleDnssdServerStateChange();
@@ -196,7 +198,7 @@ void Server::SendResponse(Header aHeader,
if (aResponseCode == Header::kResponseServerFailure)
{
otLogWarnDns("[server] failed to handle DNS query due to server failure");
LogWarn("failed to handle DNS query due to server failure");
aHeader.SetQuestionCount(0);
aHeader.SetAnswerCount(0);
aHeader.SetAdditionalRecordCount(0);
@@ -212,11 +214,11 @@ void Server::SendResponse(Header aHeader,
if (error != kErrorNone)
{
otLogWarnDns("[server] failed to send DNS-SD reply: %s", ErrorToString(error));
LogWarn("failed to send DNS-SD reply: %s", ErrorToString(error));
}
else
{
otLogInfoDns("[server] send DNS-SD reply: %s, RCODE=%d", ErrorToString(error), aResponseCode);
LogInfo("send DNS-SD reply: %s, RCODE=%d", ErrorToString(error), aResponseCode);
}
}
@@ -663,8 +665,8 @@ Header::Response Server::ResolveBySrp(Header & aResponseHeader,
response = ResolveQuestionBySrp(name, question, aResponseHeader, aResponseMessage, aCompressInfo,
/* aAdditional */ false);
otLogInfoDns("[server] ANSWER: TRANSACTION=0x%04x, QUESTION=[%s %d %d], RCODE=%d",
aResponseHeader.GetMessageId(), name, question.GetClass(), question.GetType(), response);
LogInfo("ANSWER: TRANSACTION=0x%04x, QUESTION=[%s %d %d], RCODE=%d", aResponseHeader.GetMessageId(), name,
question.GetClass(), question.GetType(), response);
}
// Answer the questions with additional RRs if required
@@ -682,8 +684,8 @@ Header::Response Server::ResolveBySrp(Header & aResponseHeader,
/* aAdditional */ true),
response = Header::kResponseServerFailure);
otLogInfoDns("[server] ADDITIONAL: TRANSACTION=0x%04x, QUESTION=[%s %d %d], RCODE=%d",
aResponseHeader.GetMessageId(), name, question.GetClass(), question.GetType(), response);
LogInfo("ADDITIONAL: TRANSACTION=0x%04x, QUESTION=[%s %d %d], RCODE=%d", aResponseHeader.GetMessageId(),
name, question.GetClass(), question.GetType(), response);
}
}
exit:
+8 -6
View File
@@ -37,7 +37,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/message.hpp"
#include "net/checksum.hpp"
#include "net/ip6.hpp"
@@ -45,6 +45,8 @@
namespace ot {
namespace Ip6 {
RegisterLogModule("Icmp6");
Icmp::Icmp(Instance &aInstance)
: InstanceLocator(aInstance)
, mEchoSequence(1)
@@ -79,7 +81,7 @@ Error Icmp::SendEchoRequest(Message &aMessage, const MessageInfo &aMessageInfo,
aMessage.SetOffset(0);
SuccessOrExit(error = Get<Ip6>().SendDatagram(aMessage, messageInfoLocal, kProtoIcmp6));
otLogInfoIcmp("Sent echo request: (seq = %d)", icmpHeader.GetSequence());
LogInfo("Sent echo request: (seq = %d)", icmpHeader.GetSequence());
exit:
return error;
@@ -116,7 +118,7 @@ Error Icmp::SendError(Header::Type aType, Header::Code aCode, const MessageInfo
SuccessOrExit(error = Get<Ip6>().SendDatagram(*message, messageInfoLocal, kProtoIcmp6));
otLogInfoIcmp("Sent ICMPv6 Error");
LogInfo("Sent ICMPv6 Error");
exit:
FreeMessageOnError(message, error);
@@ -182,14 +184,14 @@ Error Icmp::HandleEchoRequest(Message &aRequestMessage, const MessageInfo &aMess
// always handle Echo Request destined for RLOC or ALOC
VerifyOrExit(ShouldHandleEchoRequest(aMessageInfo) || aMessageInfo.GetSockAddr().GetIid().IsLocator());
otLogInfoIcmp("Received Echo Request");
LogInfo("Received Echo Request");
icmp6Header.Clear();
icmp6Header.SetType(Header::kTypeEchoReply);
if ((replyMessage = Get<Ip6>().NewMessage(0)) == nullptr)
{
otLogDebgIcmp("Failed to allocate a new message");
LogDebg("Failed to allocate a new message");
ExitNow();
}
@@ -210,7 +212,7 @@ Error Icmp::HandleEchoRequest(Message &aRequestMessage, const MessageInfo &aMess
SuccessOrExit(error = Get<Ip6>().SendDatagram(*replyMessage, replyMessageInfo, kProtoIcmp6));
IgnoreError(replyMessage->Read(replyMessage->GetOffset(), icmp6Header));
otLogInfoIcmp("Sent Echo Reply (seq = %d)", icmp6Header.GetSequence());
LogInfo("Sent Echo Reply (seq = %d)", icmp6Header.GetSequence());
exit:
FreeMessageOnError(replyMessage, error);
+22 -20
View File
@@ -40,7 +40,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/message.hpp"
#include "common/random.hpp"
#include "net/checksum.hpp"
@@ -62,6 +62,8 @@ static const IcmpType sForwardICMPTypes[] = {
namespace ot {
namespace Ip6 {
RegisterLogModule("Ip6");
Ip6::Ip6(Instance &aInstance)
: InstanceLocator(aInstance)
, mForwardingEnabled(false)
@@ -308,11 +310,11 @@ Error Ip6::InsertMplOption(Message &aMessage, Header &aHeader, MessageInfo &aMes
if ((messageCopy = aMessage.Clone()) != nullptr)
{
IgnoreError(HandleDatagram(*messageCopy, nullptr, nullptr, /* aFromHost */ true));
otLogInfoIp6("Message copy for indirect transmission to sleepy children");
LogInfo("Message copy for indirect transmission to sleepy children");
}
else
{
otLogWarnIp6("No enough buffer for message copy for indirect transmission to sleepy children");
LogWarn("No enough buffer for message copy for indirect transmission to sleepy children");
}
}
#endif
@@ -499,12 +501,12 @@ Error Ip6::SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aI
if (messageCopy != nullptr)
{
otLogInfoIp6("Message copy for indirect transmission to sleepy children");
LogInfo("Message copy for indirect transmission to sleepy children");
EnqueueDatagram(*messageCopy);
}
else
{
otLogWarnIp6("No enough buffer for message copy for indirect transmission to sleepy children");
LogWarn("No enough buffer for message copy for indirect transmission to sleepy children");
}
}
#endif
@@ -637,7 +639,7 @@ Error Ip6::FragmentDatagram(Message &aMessage, uint8_t aIpProto)
payloadFragment = payloadLeft;
payloadLeft = 0;
otLogDebgIp6("Last Fragment");
LogDebg("Last Fragment");
}
else
{
@@ -667,7 +669,7 @@ Error Ip6::FragmentDatagram(Message &aMessage, uint8_t aIpProto)
fragmentCnt++;
fragment = nullptr;
otLogInfoIp6("Fragment %d with %d bytes sent", fragmentCnt, payloadFragment);
LogInfo("Fragment %d with %d bytes sent", fragmentCnt, payloadFragment);
}
aMessage.Free();
@@ -676,7 +678,7 @@ exit:
if (error == kErrorNoBufs)
{
otLogWarnIp6("No buffer for Ip6 fragmentation");
LogWarn("No buffer for Ip6 fragmentation");
}
FreeMessageOnError(fragment, error);
@@ -720,18 +722,18 @@ Error Ip6::HandleFragment(Message &aMessage, Netif *aNetif, MessageInfo &aMessag
offset = FragmentHeader::FragmentOffsetToBytes(fragmentHeader.GetOffset());
payloadFragment = aMessage.GetLength() - aMessage.GetOffset() - sizeof(fragmentHeader);
otLogInfoIp6("Fragment with id %d received > %d bytes, offset %d", fragmentHeader.GetIdentification(),
payloadFragment, offset);
LogInfo("Fragment with id %d received > %d bytes, offset %d", fragmentHeader.GetIdentification(), payloadFragment,
offset);
if (offset + payloadFragment + aMessage.GetOffset() > kMaxAssembledDatagramLength)
{
otLogWarnIp6("Packet too large for fragment buffer");
LogWarn("Packet too large for fragment buffer");
ExitNow(error = kErrorNoBufs);
}
if (message == nullptr)
{
otLogDebgIp6("start reassembly");
LogDebg("start reassembly");
VerifyOrExit((message = NewMessage(0)) != nullptr, error = kErrorNoBufs);
mReassemblyList.Enqueue(*message);
SuccessOrExit(error = message->SetLength(aMessage.GetOffset()));
@@ -770,7 +772,7 @@ Error Ip6::HandleFragment(Message &aMessage, Netif *aNetif, MessageInfo &aMessag
header.SetNextHeader(fragmentHeader.GetNextHeader());
message->Write(0, header);
otLogDebgIp6("Reassembly complete.");
LogDebg("Reassembly complete.");
mReassemblyList.Dequeue(*message);
@@ -785,7 +787,7 @@ exit:
mReassemblyList.DequeueAndFree(*message);
}
otLogWarnIp6("Reassembly failed: %s", ErrorToString(error));
LogWarn("Reassembly failed: %s", ErrorToString(error));
}
if (isFragmented)
@@ -826,7 +828,7 @@ void Ip6::UpdateReassemblyList(void)
}
else
{
otLogNoteIp6("Reassembly timeout.");
LogNote("Reassembly timeout.");
SendIcmpError(*message, Icmp::Header::kTypeTimeExceeded, Icmp::Header::kCodeFragmReasTimeEx);
mReassemblyList.DequeueAndFree(*message);
@@ -853,7 +855,7 @@ exit:
if (error != kErrorNone)
{
otLogWarnIp6("Failed to send ICMP error: %s", ErrorToString(error));
LogWarn("Failed to send ICMP error: %s", ErrorToString(error));
}
}
@@ -966,7 +968,7 @@ Error Ip6::HandlePayload(Header & aIp6Header,
error = mTcp.HandleMessage(aIp6Header, *message, aMessageInfo);
if (error == kErrorDrop)
{
otLogNoteIp6("Error TCP Checksum");
LogNote("Error TCP Checksum");
}
break;
#endif
@@ -974,7 +976,7 @@ Error Ip6::HandlePayload(Header & aIp6Header,
error = mUdp.HandleMessage(*message, aMessageInfo);
if (error == kErrorDrop)
{
otLogNoteIp6("Error UDP Checksum");
LogNote("Error UDP Checksum");
}
break;
@@ -989,7 +991,7 @@ Error Ip6::HandlePayload(Header & aIp6Header,
exit:
if (error != kErrorNone)
{
otLogNoteIp6("Failed to handle payload: %s", ErrorToString(error));
LogNote("Failed to handle payload: %s", ErrorToString(error));
}
FreeMessage(message);
@@ -1064,7 +1066,7 @@ Error Ip6::ProcessReceiveCallback(Message & aMessage,
if (message == nullptr)
{
otLogWarnIp6("No buff to clone msg (len: %d) to pass to host", aMessage.GetLength());
LogWarn("No buff to clone msg (len: %d) to pass to host", aMessage.GetLength());
ExitNow(error = kErrorNoBufs);
}
+5 -3
View File
@@ -38,7 +38,7 @@
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "net/ip6.hpp"
#include "net/tcp6.hpp"
@@ -48,6 +48,8 @@
namespace ot {
namespace Ip6 {
RegisterLogModule("Ip6Filter");
Filter::Filter(Instance &aInstance)
: InstanceLocator(aInstance)
{
@@ -149,7 +151,7 @@ Error Filter::AddUnsecurePort(uint16_t aPort)
if (unsecurePort == 0)
{
unsecurePort = aPort;
otLogInfoIp6("Added unsecure port %d", aPort);
LogInfo("Added unsecure port %d", aPort);
ExitNow();
}
}
@@ -179,7 +181,7 @@ Error Filter::RemoveUnsecurePort(uint16_t aPort)
// Clear the last port entry.
mUnsecurePorts[i] = 0;
otLogInfoIp6("Removed unsecure port %d", aPort);
LogInfo("Removed unsecure port %d", aPort);
ExitNow();
}
}
+5 -3
View File
@@ -36,7 +36,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "net/udp6.hpp"
#include "thread/thread_netif.hpp"
@@ -48,6 +48,8 @@
namespace ot {
namespace Sntp {
RegisterLogModule("SntpClnt");
Header::Header(void)
: mFlags(kNtpVersion << kVersionOffset | kModeClient << kModeOffset)
, mStratum(0)
@@ -237,7 +239,7 @@ exit:
if (error != kErrorNone)
{
FreeMessage(messageCopy);
otLogWarnIp6("Failed to send SNTP request: %s", ErrorToString(error));
LogWarn("Failed to send SNTP request: %s", ErrorToString(error));
}
}
@@ -360,7 +362,7 @@ void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag
memcpy(kissCode, responseHeader.GetKissCode(), Header::kKissCodeLength);
kissCode[Header::kKissCodeLength] = 0;
otLogInfoIp6("SNTP response contains the Kiss-o'-death packet with %s code", kissCode);
LogInfo("SNTP response contains the Kiss-o'-death packet with %s code", kissCode);
ExitNow(error = kErrorBusy);
}
+29 -27
View File
@@ -35,7 +35,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/numeric_limits.hpp"
#include "common/random.hpp"
#include "common/settings.hpp"
@@ -50,6 +50,8 @@
namespace ot {
namespace Srp {
RegisterLogModule("SrpClient");
//---------------------------------------------------------------------
// Client::HostInfo
@@ -72,7 +74,7 @@ void Client::HostInfo::SetState(ItemState aState)
{
if (aState != GetState())
{
otLogInfoSrp("[client] HostInfo %s -> %s", ItemStateToString(GetState()), ItemStateToString(aState));
LogInfo("HostInfo %s -> %s", ItemStateToString(GetState()), ItemStateToString(aState));
mState = MapEnum(aState);
}
}
@@ -82,11 +84,11 @@ void Client::HostInfo::SetAddresses(const Ip6::Address *aAddresses, uint8_t aNum
mAddresses = aAddresses;
mNumAddresses = aNumAddresses;
otLogInfoSrp("[client] HostInfo set %d addrs", GetNumAddresses());
LogInfo("HostInfo set %d addrs", GetNumAddresses());
for (uint8_t index = 0; index < GetNumAddresses(); index++)
{
otLogInfoSrp("[client] %s", GetAddress(index).ToString().AsCString());
LogInfo("%s", GetAddress(index).ToString().AsCString());
}
}
@@ -112,8 +114,8 @@ void Client::Service::SetState(ItemState aState)
{
VerifyOrExit(GetState() != aState);
otLogInfoSrp("[client] Service %s -> %s, \"%s\" \"%s\"", ItemStateToString(GetState()), ItemStateToString(aState),
GetInstanceName(), GetName());
LogInfo("Service %s -> %s, \"%s\" \"%s\"", ItemStateToString(GetState()), ItemStateToString(aState),
GetInstanceName(), GetName());
if (aState == kToAdd)
{
@@ -133,8 +135,8 @@ void Client::Service::SetState(ItemState aState)
}
}
otLogInfoSrp("[client] subtypes:[%s] port:%d weight:%d prio:%d txts:%d", string.AsCString(), GetPort(),
GetWeight(), GetPriority(), GetNumTxtEntries());
LogInfo("subtypes:[%s] port:%d weight:%d prio:%d txts:%d", string.AsCString(), GetPort(), GetWeight(),
GetPriority(), GetNumTxtEntries());
}
mState = MapEnum(aState);
@@ -218,8 +220,8 @@ Error Client::Start(const Ip6::SockAddr &aServerSockAddr, Requester aRequester)
SuccessOrExit(error = mSocket.Open(Client::HandleUdpReceive, this));
SuccessOrExit(error = mSocket.Connect(aServerSockAddr));
otLogInfoSrp("[client] %starting, server %s", (aRequester == kRequesterUser) ? "S" : "Auto-s",
aServerSockAddr.ToString().AsCString());
LogInfo("%starting, server %s", (aRequester == kRequesterUser) ? "S" : "Auto-s",
aServerSockAddr.ToString().AsCString());
Resume();
@@ -387,7 +389,7 @@ Error Client::SetDomainName(const char *aName)
VerifyOrExit((mHostInfo.GetState() == kToAdd) || (mHostInfo.GetState() == kRemoved), error = kErrorInvalidState);
mDomainName = (aName != nullptr) ? aName : kDefaultDomainName;
otLogInfoSrp("[client] Domain name \"%s\"", mDomainName);
LogInfo("Domain name \"%s\"", mDomainName);
exit:
return error;
@@ -402,7 +404,7 @@ Error Client::SetHostName(const char *aName)
VerifyOrExit((mHostInfo.GetState() == kToAdd) || (mHostInfo.GetState() == kRemoved), error = kErrorInvalidState);
otLogInfoSrp("[client] Host name \"%s\"", aName);
LogInfo("Host name \"%s\"", aName);
mHostInfo.SetName(aName);
mHostInfo.SetState(kToAdd);
UpdateState();
@@ -506,7 +508,7 @@ Error Client::RemoveHostAndServices(bool aShouldRemoveKeyLease, bool aSendUnregT
{
Error error = kErrorNone;
otLogInfoSrp("[client] Remove host & services");
LogInfo("Remove host & services");
VerifyOrExit(mHostInfo.GetState() != kRemoved, error = kErrorAlready);
@@ -542,7 +544,7 @@ exit:
void Client::ClearHostAndServices(void)
{
otLogInfoSrp("[client] Clear host & services");
LogInfo("Clear host & services");
switch (GetState())
{
@@ -569,7 +571,7 @@ void Client::SetState(State aState)
{
VerifyOrExit(aState != mState);
otLogInfoSrp("[client] State %s -> %s", StateToString(mState), StateToString(aState));
LogInfo("State %s -> %s", StateToString(mState), StateToString(aState));
mState = aState;
switch (mState)
@@ -663,7 +665,7 @@ void Client::SendUpdate(void)
SuccessOrExit(error = PrepareUpdateMessage(*message));
SuccessOrExit(error = mSocket.SendTo(*message, Ip6::MessageInfo()));
otLogInfoSrp("[client] Send update");
LogInfo("Send update");
// State changes:
// kToAdd -> kAdding
@@ -696,7 +698,7 @@ exit:
// continue to retry using the `mRetryWaitInterval` (which keeps
// growing on each failure).
otLogInfoSrp("[client] Failed to send update: %s", ErrorToString(error));
LogInfo("Failed to send update: %s", ErrorToString(error));
FreeMessage(message);
@@ -710,7 +712,7 @@ exit:
interval = Random::NonCrypto::AddJitter(kTxFailureRetryInterval, kTxFailureRetryJitter);
mTimer.Start(interval);
otLogInfoSrp("[client] Quick retry %d in %u msec", mTxFailureRetryCount, interval);
LogInfo("Quick retry %d in %u msec", mTxFailureRetryCount, interval);
// Do not report message preparation errors to user
// until `kMaxTxFailureRetries` are exhausted.
@@ -1206,7 +1208,7 @@ void Client::ProcessResponse(Message &aMessage)
// Response is for the earlier request message.
otLogInfoSrp("[client] Received response");
LogInfo("Received response");
#if OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE
mTimoutFailureCount = 0;
@@ -1216,7 +1218,7 @@ void Client::ProcessResponse(Message &aMessage)
if (error != kErrorNone)
{
otLogInfoSrp("[client] Server rejected %s code:%d", ErrorToString(error), header.GetResponseCode());
LogInfo("Server rejected %s code:%d", ErrorToString(error), header.GetResponseCode());
if (mHostInfo.GetState() == kAdding)
{
@@ -1332,7 +1334,7 @@ void Client::ProcessResponse(Message &aMessage)
exit:
if (error != kErrorNone)
{
otLogInfoSrp("[client] Failed to process response %s", ErrorToString(error));
LogInfo("Failed to process response %s", ErrorToString(error));
}
}
@@ -1595,7 +1597,7 @@ void Client::HandleTimer(void)
case kStateUpdating:
LogRetryWaitInterval();
otLogInfoSrp("[client] Timed out, no response");
LogInfo("Timed out, no response");
GrowRetryWaitInterval();
SetState(kStateToUpdate);
InvokeCallback(kErrorResponseTimeout);
@@ -1685,7 +1687,7 @@ void Client::ProcessAutoStart(void)
ExitNow();
}
otLogInfoSrp("[client] Found anycast server %d", anycastInfo.mSequenceNumber);
LogInfo("Found anycast server %d", anycastInfo.mSequenceNumber);
serverSockAddr.SetAddress(anycastInfo.mAnycastAddress);
serverSockAddr.SetPort(kAnycastServerPort);
@@ -1866,7 +1868,7 @@ const char *Client::ItemStateToString(ItemState aState)
return kItemStateStrings[aState];
}
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_SRP == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
const char *Client::StateToString(State aState)
{
@@ -1895,11 +1897,11 @@ void Client::LogRetryWaitInterval(void) const
uint32_t interval = GetRetryWaitInterval();
otLogInfoSrp("[client] Retry interval %u %s", (interval < kLogInMsecLimit) ? interval : Time::MsecToSec(interval),
(interval < kLogInMsecLimit) ? "ms" : "sec");
LogInfo("Retry interval %u %s", (interval < kLogInMsecLimit) ? interval : Time::MsecToSec(interval),
(interval < kLogInMsecLimit) ? "ms" : "sec");
}
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_SRP == 1)
#endif // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
} // namespace Srp
} // namespace ot
+1 -1
View File
@@ -843,7 +843,7 @@ private:
#endif
#endif
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && (OPENTHREAD_CONFIG_LOG_SRP == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
static const char *StateToString(State aState);
void LogRetryWaitInterval(void) const;
#else
+39 -39
View File
@@ -39,7 +39,7 @@
#include "common/const_cast.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/new.hpp"
#include "common/random.hpp"
#include "net/dns_types.hpp"
@@ -48,6 +48,8 @@
namespace ot {
namespace Srp {
RegisterLogModule("SrpServer");
static const char kDefaultDomain[] = "default.service.arpa.";
static const char kServiceSubTypeLabel[] = "._sub.";
@@ -109,7 +111,7 @@ Error Server::SetAddressMode(AddressMode aMode)
VerifyOrExit(mState == kStateDisabled, error = kErrorInvalidState);
VerifyOrExit(mAddressMode != aMode);
otLogInfoSrp("[server] Address Mode: %s -> %s", AddressModeToString(mAddressMode), AddressModeToString(aMode));
LogInfo("Address Mode: %s -> %s", AddressModeToString(mAddressMode), AddressModeToString(aMode));
mAddressMode = aMode;
exit:
@@ -123,7 +125,7 @@ Error Server::SetAnycastModeSequenceNumber(uint8_t aSequenceNumber)
VerifyOrExit(mState == kStateDisabled, error = kErrorInvalidState);
mAnycastSequenceNumber = aSequenceNumber;
otLogInfoSrp("[server] Set Anycast Address Mode Seq Number to %d", aSequenceNumber);
LogInfo("Set Anycast Address Mode Seq Number to %d", aSequenceNumber);
exit:
return error;
@@ -272,20 +274,20 @@ void Server::RemoveHost(Host *aHost, RetainName aRetainName, NotifyMode aNotifyS
if (aRetainName)
{
otLogInfoSrp("[server] remove host '%s' (but retain its name)", aHost->GetFullName());
LogInfo("remove host '%s' (but retain its name)", aHost->GetFullName());
}
else
{
aHost->mKeyLease = 0;
IgnoreError(mHosts.Remove(*aHost));
otLogInfoSrp("[server] fully remove host '%s'", aHost->GetFullName());
LogInfo("fully remove host '%s'", aHost->GetFullName());
}
if (aNotifyServiceHandler && mServiceUpdateHandler != nullptr)
{
uint32_t updateId = AllocateId();
otLogInfoSrp("[server] SRP update handler is notified (updatedId = %u)", updateId);
LogInfo("SRP update handler is notified (updatedId = %u)", updateId);
mServiceUpdateHandler(updateId, aHost, kDefaultEventsHandlerTimeout, mServiceUpdateHandlerContext);
// We don't wait for the reply from the service update handler,
// but always remove the host (and its services) regardless of
@@ -342,14 +344,13 @@ void Server::HandleServiceUpdateResult(ServiceUpdateId aId, Error aError)
}
else
{
otLogInfoSrp("[server] delayed SRP host update result, the SRP update has been committed (updateId = %u)", aId);
LogInfo("delayed SRP host update result, the SRP update has been committed (updateId = %u)", aId);
}
}
void Server::HandleServiceUpdateResult(UpdateMetadata *aUpdate, Error aError)
{
otLogInfoSrp("[server] handler result of SRP update (id = %u) is received: %s", aUpdate->GetId(),
otThreadErrorToString(aError));
LogInfo("handler result of SRP update (id = %u) is received: %s", aUpdate->GetId(), otThreadErrorToString(aError));
IgnoreError(mOutstandingUpdates.Remove(*aUpdate));
CommitSrpUpdate(aError, *aUpdate);
@@ -413,7 +414,7 @@ void Server::CommitSrpUpdate(Error aError,
{
if (aHost.GetKeyLease() == 0)
{
otLogInfoSrp("[server] remove key of host %s", aHost.GetFullName());
LogInfo("remove key of host %s", aHost.GetFullName());
RemoveHost(existingHost, kDeleteName, kDoNotNotifyServiceHandler);
}
else if (existingHost != nullptr)
@@ -433,7 +434,7 @@ void Server::CommitSrpUpdate(Error aError,
}
else
{
otLogInfoSrp("[server] add new host %s", aHost.GetFullName());
LogInfo("add new host %s", aHost.GetFullName());
for (Service &service : aHost.GetServices())
{
@@ -497,7 +498,7 @@ void Server::SelectPort(void)
}
#endif
otLogInfoSrp("[server] selected port %u", mPort);
LogInfo("selected port %u", mPort);
}
void Server::Start(void)
@@ -506,7 +507,7 @@ void Server::Start(void)
mState = kStateRunning;
PrepareSocket();
otLogInfoSrp("[server] start listening on port %u", mPort);
LogInfo("start listening on port %u", mPort);
exit:
return;
@@ -537,7 +538,7 @@ void Server::PrepareSocket(void)
exit:
if (error != kErrorNone)
{
otLogCritSrp("[server] failed to prepare socket: %s", ErrorToString(error));
LogCrit("failed to prepare socket: %s", ErrorToString(error));
Stop();
}
}
@@ -613,7 +614,7 @@ void Server::Stop(void)
mLeaseTimer.Stop();
mOutstandingUpdatesTimer.Stop();
otLogInfoSrp("[server] stop listening on %u", mPort);
LogInfo("stop listening on %u", mPort);
IgnoreError(mSocket.Close());
mHasRegisteredAnyService = false;
@@ -660,15 +661,15 @@ void Server::ProcessDnsUpdate(Message &aMessage, MessageMetadata &aMetadata)
Error error = kErrorNone;
Host *host = nullptr;
otLogInfoSrp("[server] Received DNS update from %s",
aMetadata.IsDirectRxFromClient() ? aMetadata.mMessageInfo->GetPeerAddr().ToString().AsCString()
: "an SRPL Partner");
LogInfo("Received DNS update from %s", aMetadata.IsDirectRxFromClient()
? aMetadata.mMessageInfo->GetPeerAddr().ToString().AsCString()
: "an SRPL Partner");
SuccessOrExit(error = ProcessZoneSection(aMessage, aMetadata));
if (FindOutstandingUpdate(aMetadata) != nullptr)
{
otLogInfoSrp("[server] Drop duplicated SRP update request: MessageId=%hu", aMetadata.mDnsHeader.GetMessageId());
LogInfo("Drop duplicated SRP update request: MessageId=%hu", aMetadata.mDnsHeader.GetMessageId());
// Silently drop duplicate requests.
// This could rarely happen, because the outstanding SRP update timer should
@@ -1160,7 +1161,7 @@ exit:
mOutstandingUpdates.Push(*update);
mOutstandingUpdatesTimer.FireAtIfEarlier(update->GetExpireTime());
otLogInfoSrp("[server] SRP update handler is notified (updatedId = %u)", update->GetId());
LogInfo("SRP update handler is notified (updatedId = %u)", update->GetId());
mServiceUpdateHandler(update->GetId(), &aHost, kDefaultEventsHandlerTimeout, mServiceUpdateHandlerContext);
}
else
@@ -1190,17 +1191,17 @@ void Server::SendResponse(const Dns::UpdateHeader & aHeader,
if (aResponseCode != Dns::UpdateHeader::kResponseSuccess)
{
otLogInfoSrp("[server] send fail response: %d", aResponseCode);
LogInfo("send fail response: %d", aResponseCode);
}
else
{
otLogInfoSrp("[server] send success response");
LogInfo("send success response");
}
exit:
if (error != kErrorNone)
{
otLogWarnSrp("[server] failed to send response: %s", ErrorToString(error));
LogWarn("failed to send response: %s", ErrorToString(error));
FreeMessage(response);
}
}
@@ -1242,12 +1243,12 @@ void Server::SendResponse(const Dns::UpdateHeader &aHeader,
SuccessOrExit(error = GetSocket().SendTo(*response, aMessageInfo));
otLogInfoSrp("[server] send response with granted lease: %u and key lease: %u", aLease, aKeyLease);
LogInfo("send response with granted lease: %u and key lease: %u", aLease, aKeyLease);
exit:
if (error != kErrorNone)
{
otLogWarnSrp("[server] failed to send response: %s", ErrorToString(error));
LogWarn("failed to send response: %s", ErrorToString(error));
FreeMessage(response);
}
}
@@ -1263,7 +1264,7 @@ void Server::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag
if (error != kErrorNone)
{
otLogInfoSrp("[server] failed to handle DNS message: %s", ErrorToString(error));
LogInfo("failed to handle DNS message: %s", ErrorToString(error));
}
}
@@ -1314,7 +1315,7 @@ void Server::HandleLeaseTimer(void)
if (host->GetKeyExpireTime() <= now)
{
otLogInfoSrp("[server] KEY LEASE of host %s expired", host->GetFullName());
LogInfo("KEY LEASE of host %s expired", host->GetFullName());
// Removes the whole host and all services if the KEY RR expired.
RemoveHost(host, kDeleteName, kNotifyServiceHandler);
@@ -1347,7 +1348,7 @@ void Server::HandleLeaseTimer(void)
}
else if (host->GetExpireTime() <= now)
{
otLogInfoSrp("[server] LEASE of host %s expired", host->GetFullName());
LogInfo("LEASE of host %s expired", host->GetFullName());
// If the host expired, delete all resources of this host and its services.
for (Service &service : host->mServices)
@@ -1405,13 +1406,13 @@ void Server::HandleLeaseTimer(void)
OT_ASSERT(earliestExpireTime >= now);
if (!mLeaseTimer.IsRunning() || earliestExpireTime <= mLeaseTimer.GetFireTime())
{
otLogInfoSrp("[server] lease timer is scheduled for %u seconds", Time::MsecToSec(earliestExpireTime - now));
LogInfo("lease timer is scheduled for %u seconds", Time::MsecToSec(earliestExpireTime - now));
mLeaseTimer.StartAt(earliestExpireTime, 0);
}
}
else
{
otLogInfoSrp("[server] lease timer is stopped");
LogInfo("lease timer is stopped");
mLeaseTimer.Stop();
}
}
@@ -1425,8 +1426,7 @@ void Server::HandleOutstandingUpdatesTimer(void)
{
while (!mOutstandingUpdates.IsEmpty() && mOutstandingUpdates.GetTail()->GetExpireTime() <= TimerMilli::GetNow())
{
otLogInfoSrp("[server] outstanding service update timeout (updateId = %u)",
mOutstandingUpdates.GetTail()->GetId());
LogInfo("outstanding service update timeout (updateId = %u)", mOutstandingUpdates.GetTail()->GetId());
HandleServiceUpdateResult(mOutstandingUpdates.GetTail(), kErrorResponseTimeout);
}
}
@@ -1540,7 +1540,7 @@ exit:
return matches;
}
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && OPENTHREAD_CONFIG_LOG_SRP
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
void Server::Service::Log(Action aAction) const
{
static const char *const kActionStrings[] = {
@@ -1570,15 +1570,15 @@ void Server::Service::Log(Action aAction) const
{
IgnoreError(GetServiceSubTypeLabel(subLabel, sizeof(subLabel)));
otLogInfoSrp("[server] %s service '%s'%s%s", kActionStrings[aAction], GetInstanceName(),
IsSubType() ? " subtype:" : "", subLabel);
LogInfo("%s service '%s'%s%s", kActionStrings[aAction], GetInstanceName(), IsSubType() ? " subtype:" : "",
subLabel);
}
}
#else
void Server::Service::Log(Action) const
{
}
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO) && OPENTHREAD_CONFIG_LOG_SRP
#endif // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
//---------------------------------------------------------------------------------------------------------------------
// Server::Service::Description
@@ -1768,7 +1768,7 @@ void Server::Host::RemoveService(Service *aService, RetainName aRetainName, Noti
{
uint32_t updateId = server.AllocateId();
otLogInfoSrp("[server] SRP update handler is notified (updatedId = %u)", updateId);
LogInfo("SRP update handler is notified (updatedId = %u)", updateId);
server.mServiceUpdateHandler(updateId, this, kDefaultEventsHandlerTimeout, server.mServiceUpdateHandlerContext);
// We don't wait for the reply from the service update handler,
// but always remove the service regardless of service update result.
@@ -1808,7 +1808,7 @@ Error Server::Host::MergeServicesAndResourcesFrom(Host &aHost)
Error error = kErrorNone;
otLogInfoSrp("[server] update host %s", GetFullName());
LogInfo("update host %s", GetFullName());
mAddresses = aHost.mAddresses;
mKeyRecord = aHost.mKeyRecord;
@@ -1909,7 +1909,7 @@ Error Server::Host::AddIp6Address(const Ip6::Address &aIp6Address)
if (error == kErrorNoBufs)
{
otLogWarnSrp("[server] too many addresses for host %s", GetFullName());
LogWarn("too many addresses for host %s", GetFullName());
}
exit:
+13 -11
View File
@@ -41,7 +41,7 @@
#include "common/code_utils.hpp"
#include "common/error.hpp"
#include "common/instance.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/random.hpp"
#include "net/checksum.hpp"
#include "net/ip6.hpp"
@@ -55,6 +55,8 @@ namespace Ip6 {
using ot::Encoding::BigEndian::HostSwap16;
using ot::Encoding::BigEndian::HostSwap32;
RegisterLogModule("Tcp");
Tcp::Tcp(Instance &aInstance)
: InstanceLocator(aInstance)
, mTimer(aInstance, Tcp::HandleTimer)
@@ -319,8 +321,8 @@ void Tcp::Endpoint::SetTimer(uint8_t aTimerFlag, uint32_t aDelay)
uint8_t timerIndex = TimerFlagToIndex(aTimerFlag);
mTimers[timerIndex] = newFireTime.GetValue();
otLogDebgTcp("Endpoint %p set timer %u to %u ms", static_cast<void *>(this), static_cast<unsigned int>(timerIndex),
static_cast<unsigned int>(aDelay));
LogDebg("Endpoint %p set timer %u to %u ms", static_cast<void *>(this), static_cast<unsigned int>(timerIndex),
static_cast<unsigned int>(aDelay));
GetInstance().Get<Tcp>().mTimer.FireAtIfEarlier(newFireTime);
}
@@ -335,8 +337,8 @@ void Tcp::Endpoint::CancelTimer(uint8_t aTimerFlag)
OT_UNUSED_VARIABLE(aTimerFlag);
otLogDebgTcp("Endpoint %p cancelled timer %u", static_cast<void *>(this),
static_cast<unsigned int>(TimerFlagToIndex(aTimerFlag)));
LogDebg("Endpoint %p cancelled timer %u", static_cast<void *>(this),
static_cast<unsigned int>(TimerFlagToIndex(aTimerFlag)));
}
bool Tcp::Endpoint::FirePendingTimers(TimeMilli aNow, bool &aHasFutureTimer, TimeMilli &aEarliestFutureExpiry)
@@ -727,7 +729,7 @@ exit:
void Tcp::HandleTimer(Timer &aTimer)
{
OT_ASSERT(&aTimer == &aTimer.GetInstance().Get<Tcp>().mTimer);
otLogDebgTcp("Main TCP timer expired");
LogDebg("Main TCP timer expired");
aTimer.GetInstance().Get<Tcp>().ProcessTimers();
}
@@ -785,11 +787,11 @@ restart:
* timers.
*/
mTimer.FireAtIfEarlier(earliestPendingTimerExpiry);
otLogDebgTcp("Reset main TCP timer to %u ms", static_cast<unsigned int>(earliestPendingTimerExpiry - now));
LogDebg("Reset main TCP timer to %u ms", static_cast<unsigned int>(earliestPendingTimerExpiry - now));
}
else
{
otLogDebgTcp("Did not reset main TCP timer");
LogDebg("Did not reset main TCP timer");
}
}
@@ -837,7 +839,7 @@ void tcplp_sys_send_message(otInstance *aInstance, otMessage *aMessage, otMessag
Message & message = AsCoreType(aMessage);
MessageInfo &info = AsCoreType(aMessageInfo);
otLogDebgTcp("Sending TCP segment: payload_size = %d", static_cast<int>(message.GetLength()));
LogDebg("Sending TCP segment: payload_size = %d", static_cast<int>(message.GetLength()));
IgnoreError(instance.Get<ot::Ip6::Ip6>().SendDatagram(message, info, kProtoTcp));
}
@@ -986,7 +988,7 @@ void tcplp_sys_log(const char *aFormat, ...)
vsnprintf(buffer, sizeof(buffer), aFormat, args);
va_end(args);
otLogDebgTcp(buffer);
LogDebg(buffer);
}
void tcplp_sys_panic(const char *aFormat, ...)
@@ -997,7 +999,7 @@ void tcplp_sys_panic(const char *aFormat, ...)
vsnprintf(buffer, sizeof(buffer), aFormat, args);
va_end(args);
otLogCritTcp(buffer);
LogCrit("%s", buffer);
OT_ASSERT(false);
}
+13 -11
View File
@@ -42,13 +42,15 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/string.hpp"
#include "net/dns_types.hpp"
namespace ot {
namespace Trel {
RegisterLogModule("TrelInterface");
const char Interface::kTxtRecordExtAddressKey[] = "xa";
const char Interface::kTxtRecordExtPanIdKey[] = "xp";
@@ -83,7 +85,7 @@ void Interface::Enable(void)
otPlatTrelEnable(&GetInstance(), &mUdpPort);
otLogInfoMac("Trel: Enabled interface, local port:%u", mUdpPort);
LogInfo("Enabled interface, local port:%u", mUdpPort);
mRegisterServiceTask.Post();
exit:
@@ -99,7 +101,7 @@ void Interface::Disable(void)
otPlatTrelDisable(&GetInstance());
mPeerTable.Clear();
otLogDebgMac("Trel: Disabled interface");
LogDebg("Disabled interface");
exit:
return;
@@ -108,7 +110,7 @@ exit:
void Interface::HandleExtAddressChange(void)
{
VerifyOrExit(mInitialized && mEnabled);
otLogDebgMac("Trel: Extended Address changed, re-registering DNS-SD service");
LogDebg("Extended Address changed, re-registering DNS-SD service");
mRegisterServiceTask.Post();
exit:
@@ -118,7 +120,7 @@ exit:
void Interface::HandleExtPanIdChange(void)
{
VerifyOrExit(mInitialized && mEnabled);
otLogDebgMac("Trel: Extended PAN ID changed, re-registering DNS-SD service");
LogDebg("Extended PAN ID changed, re-registering DNS-SD service");
mRegisterServiceTask.Post();
exit:
@@ -151,9 +153,9 @@ void Interface::RegisterService(void)
txtData.Init(txtDataBuffer, sizeof(txtDataBuffer));
SuccessOrAssert(Dns::TxtEntry::AppendEntries(txtEntries, GetArrayLength(txtEntries), txtData));
otLogInfoMac("Trel: Registering DNS-SD service: port:%u, txt:\"%s=%s, %s=%s\"", mUdpPort, kTxtRecordExtAddressKey,
Get<Mac::Mac>().GetExtAddress().ToString().AsCString(), kTxtRecordExtPanIdKey,
Get<Mac::Mac>().GetExtendedPanId().ToString().AsCString());
LogInfo("Registering DNS-SD service: port:%u, txt:\"%s=%s, %s=%s\"", mUdpPort, kTxtRecordExtAddressKey,
Get<Mac::Mac>().GetExtAddress().ToString().AsCString(), kTxtRecordExtPanIdKey,
Get<Mac::Mac>().GetExtendedPanId().ToString().AsCString());
otPlatTrelRegisterService(&GetInstance(), mUdpPort, txtData.GetBytes(), static_cast<uint8_t>(txtData.GetLength()));
@@ -385,7 +387,7 @@ exit:
void Interface::HandleReceived(uint8_t *aBuffer, uint16_t aLength)
{
otLogDebgMac("Trel: HandleReceived(aLength:%u)", aLength);
LogDebg("HandleReceived(aLength:%u)", aLength);
VerifyOrExit(mInitialized && mEnabled && !mFiltered);
@@ -412,8 +414,8 @@ void Interface::Peer::Log(const char *aAction) const
{
OT_UNUSED_VARIABLE(aAction);
otLogInfoMac("Trel: %s peer mac:%s, xpan:%s, %s", aAction, GetExtAddress().ToString().AsCString(),
GetExtPanId().ToString().AsCString(), GetSockAddr().ToString().AsCString());
LogInfo("%s peer mac:%s, xpan:%s, %s", aAction, GetExtAddress().ToString().AsCString(),
GetExtPanId().ToString().AsCString(), GetSockAddr().ToString().AsCString());
}
} // namespace Trel
+10 -10
View File
@@ -38,11 +38,13 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
namespace ot {
namespace Trel {
RegisterLogModule("TrelLink");
Link::Link(Instance &aInstance)
: InstanceLocator(aInstance)
, mState(kStateDisabled)
@@ -219,8 +221,7 @@ void Link::BeginTransmit(void)
txPacket.GetHeader().SetDestination(destAddr.GetExtended());
}
otLogDebgMac("Trel: BeginTransmit() [%s] plen:%d", txPacket.GetHeader().ToString().AsCString(),
txPacket.GetPayloadLength());
LogDebg("BeginTransmit() [%s] plen:%d", txPacket.GetHeader().ToString().AsCString(), txPacket.GetPayloadLength());
VerifyOrExit(mInterface.Send(txPacket, isDisovery) == kErrorNone, InvokeSendDone(kErrorAbort));
@@ -372,8 +373,7 @@ void Link::ProcessReceivedPacket(Packet &aPacket)
}
}
otLogDebgMac("Trel: ReceivedPacket() [%s] plen:%d", aPacket.GetHeader().ToString().AsCString(),
aPacket.GetPayloadLength());
LogDebg("ReceivedPacket() [%s] plen:%d", aPacket.GetHeader().ToString().AsCString(), aPacket.GetPayloadLength());
if (aPacket.GetHeader().GetAckMode() == Header::kAckRequested)
{
@@ -404,7 +404,7 @@ void Link::HandleAck(Packet &aAckPacket)
Neighbor * neighbor;
uint32_t ackNumber;
otLogDebgMac("Trel: HandleAck() [%s]", aAckPacket.GetHeader().ToString().AsCString());
LogDebg("HandleAck() [%s]", aAckPacket.GetHeader().ToString().AsCString());
srcAddress.SetExtended(aAckPacket.GetHeader().GetSource());
neighbor = Get<NeighborTable>().FindNeighbor(srcAddress, Neighbor::kInStateAnyExceptInvalid);
@@ -450,15 +450,15 @@ void Link::SendAck(Packet &aRxPacket)
ackPacket.GetHeader().SetSource(Get<Mac::Mac>().GetExtAddress());
ackPacket.GetHeader().SetDestination(aRxPacket.GetHeader().GetSource());
otLogDebgMac("Trel: SendAck [%s]", ackPacket.GetHeader().ToString().AsCString());
LogDebg("SendAck [%s]", ackPacket.GetHeader().ToString().AsCString());
IgnoreError(mInterface.Send(ackPacket));
}
void Link::ReportDeferredAckStatus(Neighbor &aNeighbor, Error aError)
{
otLogDebgMac("Trel: ReportDeferredAckStatus(): %s for %s", aNeighbor.GetExtAddress().ToString().AsCString(),
ErrorToString(aError));
LogDebg("ReportDeferredAckStatus(): %s for %s", aNeighbor.GetExtAddress().ToString().AsCString(),
ErrorToString(aError));
Get<MeshForwarder>().HandleDeferredAck(aNeighbor, aError);
}
@@ -467,7 +467,7 @@ void Link::SetState(State aState)
{
if (mState != aState)
{
otLogDebgMac("Trel: State: %s -> %s", StateToString(mState), StateToString(aState));
LogDebg("State: %s -> %s", StateToString(mState), StateToString(aState));
mState = aState;
}
}
-1
View File
@@ -38,7 +38,6 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
namespace ot {
namespace Trel {
+25 -25
View File
@@ -42,7 +42,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/time.hpp"
#include "mac/mac_types.hpp"
#include "thread/mesh_forwarder.hpp"
@@ -52,6 +52,8 @@
namespace ot {
RegisterLogModule("AddrResolver");
AddressResolver::AddressResolver(Instance &aInstance)
: InstanceLocator(aInstance)
, mAddressError(UriPath::kAddressError, &AddressResolver::HandleAddressError, this)
@@ -573,7 +575,7 @@ Error AddressResolver::SendAddressQuery(const Ip6::Address &aEid)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoArp("Sending address query for %s", aEid.ToString().AsCString());
LogInfo("Sending address query for %s", aEid.ToString().AsCString());
exit:
@@ -585,8 +587,8 @@ exit:
{
uint16_t selfRloc16 = Get<Mle::MleRouter>().GetRloc16();
otLogInfoArp("Extending ADDR.qry to BB.qry for target=%s, rloc16=%04x(self)", aEid.ToString().AsCString(),
selfRloc16);
LogInfo("Extending ADDR.qry to BB.qry for target=%s, rloc16=%04x(self)", aEid.ToString().AsCString(),
selfRloc16);
IgnoreError(Get<BackboneRouter::Manager>().SendBackboneQuery(aEid, selfRloc16));
}
#endif
@@ -627,8 +629,8 @@ void AddressResolver::HandleAddressNotification(Coap::Message &aMessage, const I
ExitNow();
}
otLogInfoArp("Received address notification from 0x%04x for %s to 0x%04x",
aMessageInfo.GetPeerAddr().GetIid().GetLocator(), target.ToString().AsCString(), rloc16);
LogInfo("Received address notification from 0x%04x for %s to 0x%04x",
aMessageInfo.GetPeerAddr().GetIid().GetLocator(), target.ToString().AsCString(), rloc16);
entry = FindCacheEntry(target, list, prev);
VerifyOrExit(entry != nullptr);
@@ -659,7 +661,7 @@ void AddressResolver::HandleAddressNotification(Coap::Message &aMessage, const I
if (Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo) == kErrorNone)
{
otLogInfoArp("Sending address notification acknowledgment");
LogInfo("Sending address notification acknowledgment");
}
Get<MeshForwarder>().HandleResolved(target, kErrorNone);
@@ -699,14 +701,14 @@ void AddressResolver::SendAddressError(const Ip6::Address & aTarget,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoArp("Sending address error for target %s", aTarget.ToString().AsCString());
LogInfo("Sending address error for target %s", aTarget.ToString().AsCString());
exit:
if (error != kErrorNone)
{
FreeMessage(message);
otLogInfoArp("Failed to send address error: %s", ErrorToString(error));
LogInfo("Failed to send address error: %s", ErrorToString(error));
}
}
@@ -725,13 +727,13 @@ void AddressResolver::HandleAddressError(Coap::Message &aMessage, const Ip6::Mes
VerifyOrExit(aMessage.IsPostRequest(), error = kErrorDrop);
otLogInfoArp("Received address error notification");
LogInfo("Received address error notification");
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
if (Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo) == kErrorNone)
{
otLogInfoArp("Sent address error notification acknowledgment");
LogInfo("Sent address error notification acknowledgment");
}
}
@@ -786,7 +788,7 @@ exit:
if (error != kErrorNone)
{
otLogWarnArp("Error while processing address error notification: %s", ErrorToString(error));
LogWarn("Error while processing address error notification: %s", ErrorToString(error));
}
}
@@ -804,8 +806,8 @@ void AddressResolver::HandleAddressQuery(Coap::Message &aMessage, const Ip6::Mes
SuccessOrExit(Tlv::Find<ThreadTargetTlv>(aMessage, target));
otLogInfoArp("Received address query from 0x%04x for target %s", aMessageInfo.GetPeerAddr().GetIid().GetLocator(),
target.ToString().AsCString());
LogInfo("Received address query from 0x%04x for target %s", aMessageInfo.GetPeerAddr().GetIid().GetLocator(),
target.ToString().AsCString());
if (Get<ThreadNetif>().HasUnicastAddress(target))
{
@@ -834,8 +836,7 @@ void AddressResolver::HandleAddressQuery(Coap::Message &aMessage, const Ip6::Mes
{
uint16_t srcRloc16 = aMessageInfo.GetPeerAddr().GetIid().GetLocator();
otLogInfoArp("Extending ADDR.qry to BB.qry for target=%s, rloc16=%04x", target.ToString().AsCString(),
srcRloc16);
LogInfo("Extending ADDR.qry to BB.qry for target=%s, rloc16=%04x", target.ToString().AsCString(), srcRloc16);
IgnoreError(Get<BackboneRouter::Manager>().SendBackboneQuery(target, srcRloc16));
}
#endif
@@ -874,7 +875,7 @@ void AddressResolver::SendAddressQueryResponse(const Ip6::Address & a
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoArp("Sending address notification for target %s", aTarget.ToString().AsCString());
LogInfo("Sending address notification for target %s", aTarget.ToString().AsCString());
exit:
FreeMessageOnError(message, error);
@@ -942,8 +943,8 @@ void AddressResolver::HandleTimeTick(void)
mQueryList.PopAfter(prev);
mQueryRetryList.Push(*entry);
otLogInfoArp("Timed out waiting for address notification for %s, retry: %d",
entry->GetTarget().ToString().AsCString(), entry->GetTimeout());
LogInfo("Timed out waiting for address notification for %s, retry: %d",
entry->GetTarget().ToString().AsCString(), entry->GetTimeout());
Get<MeshForwarder>().HandleResolved(entry->GetTarget(), kErrorDrop);
@@ -994,7 +995,7 @@ exit:
// LCOV_EXCL_START
#if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && (OPENTHREAD_CONFIG_LOG_ARP == 1)
#if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
void AddressResolver::LogCacheEntryChange(EntryChange aChange,
Reason aReason,
@@ -1031,9 +1032,8 @@ void AddressResolver::LogCacheEntryChange(EntryChange aChange,
static_assert(6 == kReasonEvictingForNewEntry, "kReasonEvictingForNewEntry value is incorrect");
static_assert(7 == kReasonRemovingEid, "kReasonRemovingEid value is incorrect");
otLogNoteArp("Cache entry %s: %s, 0x%04x%s%s - %s", kChangeStrings[aChange],
aEntry.GetTarget().ToString().AsCString(), aEntry.GetRloc16(),
(aList == nullptr) ? "" : ", list:", ListToString(aList), kReasonStrings[aReason]);
LogNote("Cache entry %s: %s, 0x%04x%s%s - %s", kChangeStrings[aChange], aEntry.GetTarget().ToString().AsCString(),
aEntry.GetRloc16(), (aList == nullptr) ? "" : ", list:", ListToString(aList), kReasonStrings[aReason]);
}
const char *AddressResolver::ListToString(const CacheEntryList *aList) const
@@ -1049,13 +1049,13 @@ exit:
return str;
}
#else // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && (OPENTHREAD_CONFIG_LOG_ARP == 1)
#else // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
void AddressResolver::LogCacheEntryChange(EntryChange, Reason, const CacheEntry &, CacheEntryList *)
{
}
#endif // #if (OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE) && (OPENTHREAD_CONFIG_LOG_ARP == 1)
#endif // #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_NOTE
// LCOV_EXCL_STOP
+4 -2
View File
@@ -41,13 +41,15 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/thread_netif.hpp"
#include "thread/uri_paths.hpp"
namespace ot {
RegisterLogModule("MeshCoP");
AnnounceBeginServer::AnnounceBeginServer(Instance &aInstance)
: AnnounceSenderBase(aInstance, AnnounceBeginServer::HandleTimer)
, mAnnounceBegin(UriPath::kAnnounceBegin, &AnnounceBeginServer::HandleRequest, this)
@@ -86,7 +88,7 @@ void AnnounceBeginServer::HandleRequest(Coap::Message &aMessage, const Ip6::Mess
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, responseInfo));
otLogInfoMeshCoP("sent announce begin response");
LogInfo("Sent announce begin response");
}
exit:
+8 -6
View File
@@ -38,7 +38,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/random.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
@@ -46,6 +46,8 @@
namespace ot {
RegisterLogModule("AnnounceSender");
//---------------------------------------------------------------------------------------------------------------------
// AnnounceSenderBase
@@ -168,7 +170,7 @@ void AnnounceSender::Stop(void)
{
AnnounceSenderBase::Stop();
mTrickleTimer.Stop();
otLogInfoMle("[announce-sender] Stopped");
LogInfo("Stopped");
}
void AnnounceSender::HandleTimer(Timer &aTimer)
@@ -191,7 +193,7 @@ void AnnounceSender::HandleTrickleTimer(void)
// message transmissions.
SendAnnounce(1);
otLogInfoMle("[announce-sender] Schedule tx for one cycle");
LogInfo("Schedule tx for one cycle");
}
void AnnounceSender::HandleNotifierEvents(Events aEvents)
@@ -240,7 +242,7 @@ void AnnounceSender::HandleRoleChanged(void)
// desired Announce Tx cycle interval.
mTrickleTimer.Start(TrickleTimer::kModeTrickle, kInterval, kInterval, kRedundancyConstant);
otLogInfoMle("[announce-sender] Started");
LogInfo("Started");
exit:
return;
@@ -257,7 +259,7 @@ void AnnounceSender::HandleActiveDatasetChanged(void)
SetChannelMask(channelMask);
SetPeriod(kTxInterval / channelMask.GetNumberOfChannels());
otLogInfoMle("[announce-sender] ChannelMask:%s, period:%u", GetChannelMask().ToString().AsCString(), GetPeriod());
LogInfo("ChannelMask:%s, period:%u", GetChannelMask().ToString().AsCString(), GetPeriod());
// When channel mask is changed, we also check and update the PAN
// channel. This handles the case where `ThreadChannelChanged` event
@@ -273,7 +275,7 @@ exit:
void AnnounceSender::HandleThreadChannelChanged(void)
{
SetStartingChannel(Get<Mac::Mac>().GetPanChannel());
otLogInfoMle("[announce-sender] StartingChannel:%d", GetStartingChannel());
LogInfo("StartingChannel:%d", GetStartingChannel());
}
#endif // OPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE
+5 -3
View File
@@ -31,12 +31,14 @@
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/time.hpp"
#include "mac/mac.hpp"
namespace ot {
RegisterLogModule("CslTxScheduler");
CslTxScheduler::Callbacks::Callbacks(Instance &aInstance)
: InstanceLocator(aInstance)
{
@@ -253,8 +255,8 @@ void CslTxScheduler::HandleSentFrame(const Mac::TxFrame &aFrame, Error aError, C
OT_ASSERT(!aFrame.GetSecurityEnabled() || aFrame.IsHeaderUpdated());
aChild.IncrementCslTxAttempts();
otLogInfoMac("CSL tx to child %04x failed, attempt %d/%d", aChild.GetRloc16(), aChild.GetCslTxAttempts(),
kMaxCslTriggeredTxAttempts);
LogInfo("CSL tx to child %04x failed, attempt %d/%d", aChild.GetRloc16(), aChild.GetCslTxAttempts(),
kMaxCslTriggeredTxAttempts);
if (aChild.GetCslTxAttempts() >= kMaxCslTriggeredTxAttempts)
{
-1
View File
@@ -37,7 +37,6 @@
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "thread/mesh_forwarder.hpp"
#include "thread/mle.hpp"
#include "thread/mle_router.hpp"
+21 -19
View File
@@ -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));
}
}
+5 -3
View File
@@ -39,7 +39,7 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "thread/thread_netif.hpp"
@@ -47,6 +47,8 @@
namespace ot {
RegisterLogModule("EnergyScanSrv");
EnergyScanServer::EnergyScanServer(Instance &aInstance)
: InstanceLocator(aInstance)
, mChannelMask(0)
@@ -97,7 +99,7 @@ void EnergyScanServer::HandleRequest(Coap::Message &aMessage, const Ip6::Message
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, responseInfo));
otLogInfoMeshCoP("sent energy scan query response");
LogInfo("sent energy scan query response");
}
exit:
@@ -194,7 +196,7 @@ void EnergyScanServer::SendReport(void)
messageInfo.SetPeerPort(Tmf::kUdpPort);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent scan results");
LogInfo("sent scan results");
exit:
FreeMessageOnError(message, error);
-1
View File
@@ -38,7 +38,6 @@
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/message.hpp"
#include "thread/mesh_forwarder.hpp"
#include "thread/mle_tlvs.hpp"
+4 -2
View File
@@ -37,7 +37,7 @@
#include "common/encoding.hpp"
#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/logging.hpp"
#include "common/log.hpp"
#include "common/timer.hpp"
#include "crypto/hkdf_sha256.hpp"
#include "crypto/storage.hpp"
@@ -46,6 +46,8 @@
namespace ot {
RegisterLogModule("KeyManager");
const uint8_t KeyManager::kThreadString[] = {
'T', 'h', 'r', 'e', 'a', 'd',
};
@@ -486,7 +488,7 @@ void KeyManager::SetSecurityPolicy(const SecurityPolicy &aSecurityPolicy)
{
if (aSecurityPolicy.mRotationTime < SecurityPolicy::kMinKeyRotationTime)
{
otLogNoteMeshCoP("Key Rotation Time too small: %d", aSecurityPolicy.mRotationTime);
LogNote("Key Rotation Time too small: %d", aSecurityPolicy.mRotationTime);
ExitNow();
}

Some files were not shown because too many files have changed in this diff Show More