From d4cd57f904d8906a68495469b2a3148631e5904d Mon Sep 17 00:00:00 2001 From: Marcin K Szczodrak Date: Mon, 19 Dec 2016 13:46:03 -0800 Subject: [PATCH] allow product config to disable a log region (#1090) --- src/core/common/logging.hpp | 46 +++++++++++----------- src/core/openthread-core-default-config.h | 48 +++++++++++++++++------ 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/src/core/common/logging.hpp b/src/core/common/logging.hpp index 13e33e6f8..f3dbd83f6 100644 --- a/src/core/common/logging.hpp +++ b/src/core/common/logging.hpp @@ -168,7 +168,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_API +#if OPENTHREAD_CONFIG_LOG_API == 1 #define otLogCritApi(aFormat, ...) otLogCrit(kLogRegionApi, aFormat, ## __VA_ARGS__) #define otLogWarnApi(aFormat, ...) otLogWarn(kLogRegionApi, aFormat, ## __VA_ARGS__) #define otLogInfoApi(aFormat, ...) otLogInfo(kLogRegionApi, aFormat, ## __VA_ARGS__) @@ -219,7 +219,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MLE +#if OPENTHREAD_CONFIG_LOG_MLE == 1 #define otLogCritMeshCoP(aFormat, ...) otLogCrit(kLogRegionMeshCoP, aFormat, ## __VA_ARGS__) #define otLogWarnMeshCoP(aFormat, ...) otLogWarn(kLogRegionMeshCoP, aFormat, ## __VA_ARGS__) #define otLogInfoMeshCoP(aFormat, ...) otLogInfo(kLogRegionMeshCoP, aFormat, ## __VA_ARGS__) @@ -275,7 +275,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MLE +#if OPENTHREAD_CONFIG_LOG_MLE == 1 #define otLogCritMle(aFormat, ...) otLogCrit(kLogRegionMle, aFormat, ## __VA_ARGS__) #define otLogWarnMle(aFormat, ...) otLogWarn(kLogRegionMle, aFormat, ## __VA_ARGS__) #define otLogWarnMleErr(aError, aFormat, ...) otLogWarn(kLogRegionMac, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__) @@ -328,7 +328,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_ARP +#if OPENTHREAD_CONFIG_LOG_ARP == 1 #define otLogCritArp(aFormat, ...) otLogCrit(kLogRegionArp, aFormat, ## __VA_ARGS__) #define otLogWarnArp(aFormat, ...) otLogWarn(kLogRegionArp, aFormat, ## __VA_ARGS__) #define otLogInfoArp(aFormat, ...) otLogInfo(kLogRegionArp, aFormat, ## __VA_ARGS__) @@ -379,7 +379,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_NETDATA +#if OPENTHREAD_CONFIG_LOG_NETDATA == 1 #define otLogCritNetData(aFormat, ...) otLogCrit(kLogRegionNetData, aFormat, ## __VA_ARGS__) #define otLogWarnNetData(aFormat, ...) otLogWarn(kLogRegionNetData, aFormat, ## __VA_ARGS__) #define otLogInfoNetData(aFormat, ...) otLogInfo(kLogRegionNetData, aFormat, ## __VA_ARGS__) @@ -430,7 +430,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_ICMP +#if OPENTHREAD_CONFIG_LOG_ICMP == 1 #define otLogCritIcmp(aFormat, ...) otLogCrit(kLogRegionIcmp, aFormat, ## __VA_ARGS__) #define otLogWarnIcmp(aFormat, ...) otLogWarn(kLogRegionIcmp, aFormat, ## __VA_ARGS__) #define otLogInfoIcmp(aFormat, ...) otLogInfo(kLogRegionIcmp, aFormat, ## __VA_ARGS__) @@ -481,7 +481,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_IP6 +#if OPENTHREAD_CONFIG_LOG_IP6 == 1 #define otLogCritIp6(aFormat, ...) otLogCrit(kLogRegionIp6, aFormat, ## __VA_ARGS__) #define otLogWarnIp6(aFormat, ...) otLogWarn(kLogRegionIp6, aFormat, ## __VA_ARGS__) #define otLogInfoIp6(aFormat, ...) otLogInfo(kLogRegionIp6, aFormat, ## __VA_ARGS__) @@ -532,7 +532,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MAC +#if OPENTHREAD_CONFIG_LOG_MAC == 1 #define otLogCritMac(aFormat, ...) otLogCrit(kLogRegionMac, aFormat, ## __VA_ARGS__) #define otLogWarnMac(aFormat, ...) otLogWarn(kLogRegionMac, aFormat, ## __VA_ARGS__) #define otLogInfoMac(aFormat, ...) otLogInfo(kLogRegionMac, aFormat, ## __VA_ARGS__) @@ -585,7 +585,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MEM +#if OPENTHREAD_CONFIG_LOG_MEM == 1 #define otLogCritMem(aFormat, ...) otLogCrit(kLogRegionMem, aFormat, ## __VA_ARGS__) #define otLogWarnMem(aFormat, ...) otLogWarn(kLogRegionMem, aFormat, ## __VA_ARGS__) #define otLogInfoMem(aFormat, ...) otLogInfo(kLogRegionMem, aFormat, ## __VA_ARGS__) @@ -636,7 +636,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_NETDIAG +#if OPENTHREAD_CONFIG_LOG_NETDIAG == 1 #define otLogCritNetDiag(aFormat, ...) otLogCrit(kLogRegionNetDiag, aFormat, ## __VA_ARGS__) #define otLogWarnNetDiag(aFormat, ...) otLogWarn(kLogRegionNetDiag, aFormat, ## __VA_ARGS__) #define otLogInfoNetDiag(aFormat, ...) otLogInfo(kLogRegionNetDiag, aFormat, ## __VA_ARGS__) @@ -702,7 +702,7 @@ extern "C" { * @param[in] ... Arguments for the format specification. * */ -#ifdef OPENTHREAD_CONFIG_LOG_PLATFORM +#if OPENTHREAD_CONFIG_LOG_PLATFORM == 1 #define otLogCritPlat(aFormat, ...) otLogCrit(kLogRegionPlatform, aFormat, ## __VA_ARGS__) #define otLogWarnPlat(aFormat, ...) otLogWarn(kLogRegionPlatform, aFormat, ## __VA_ARGS__) #define otLogInfoPlat(aFormat, ...) otLogInfo(kLogRegionPlatform, aFormat, ## __VA_ARGS__) @@ -827,7 +827,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_NETDATA +#if OPENTHREAD_CONFIG_LOG_NETDATA == 1 #define otDumpCritNetData(aId, aBuf, aLength) otDumpCrit(kLogRegionNetData, aId, aBuf, aLength) #define otDumpWarnNetData(aId, aBuf, aLength) otDumpWarn(kLogRegionNetData, aId, aBuf, aLength) #define otDumpInfoNetData(aId, aBuf, aLength) otDumpInfo(kLogRegionNetData, aId, aBuf, aLength) @@ -882,7 +882,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MLE +#if OPENTHREAD_CONFIG_LOG_MLE == 1 #define otDumpCritMle(aId, aBuf, aLength) otDumpCrit(kLogRegionMle, aId, aBuf, aLength) #define otDumpWarnMle(aId, aBuf, aLength) otDumpWarn(kLogRegionMle, aId, aBuf, aLength) #define otDumpInfoMle(aId, aBuf, aLength) otDumpInfo(kLogRegionMle, aId, aBuf, aLength) @@ -937,7 +937,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_ARP +#if OPENTHREAD_CONFIG_LOG_ARP == 1 #define otDumpCritArp(aId, aBuf, aLength) otDumpCrit(kLogRegionArp, aId, aBuf, aLength) #define otDumpWarnArp(aId, aBuf, aLength) otDumpWarn(kLogRegionArp, aId, aBuf, aLength) #define otDumpInfoArp(aId, aBuf, aLength) otDumpInfo(kLogRegionArp, aId, aBuf, aLength) @@ -992,7 +992,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_ICMP +#if OPENTHREAD_CONFIG_LOG_ICMP == 1 #define otDumpCritIcmp(aId, aBuf, aLength) otDumpCrit(kLogRegionIcmp, aId, aBuf, aLength) #define otDumpWarnIcmp(aId, aBuf, aLength) otDumpWarn(kLogRegionIcmp, aId, aBuf, aLength) #define otDumpInfoIcmp(aId, aBuf, aLength) otDumpInfo(kLogRegionIcmp, aId, aBuf, aLength) @@ -1047,7 +1047,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_IP6 +#if OPENTHREAD_CONFIG_LOG_IP6 == 1 #define otDumpCritIp6(aId, aBuf, aLength) otDumpCrit(kLogRegionIp6, aId, aBuf, aLength) #define otDumpWarnIp6(aId, aBuf, aLength) otDumpWarn(kLogRegionIp6, aId, aBuf, aLength) #define otDumpInfoIp6(aId, aBuf, aLength) otDumpInfo(kLogRegionIp6, aId, aBuf, aLength) @@ -1102,7 +1102,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MAC +#if OPENTHREAD_CONFIG_LOG_MAC == 1 #define otDumpCritMac(aId, aBuf, aLength) otDumpCrit(kLogRegionMac, aId, aBuf, aLength) #define otDumpWarnMac(aId, aBuf, aLength) otDumpWarn(kLogRegionMac, aId, aBuf, aLength) #define otDumpInfoMac(aId, aBuf, aLength) otDumpInfo(kLogRegionMac, aId, aBuf, aLength) @@ -1157,7 +1157,7 @@ extern "C" { * @param[in] aLength Number of bytes to print. * */ -#ifdef OPENTHREAD_CONFIG_LOG_MEM +#if OPENTHREAD_CONFIG_LOG_MEM == 1 #define otDumpCritMem(aId, aBuf, aLength) otDumpCrit(kLogRegionMem, aId, aBuf, aLength) #define otDumpWarnMem(aId, aBuf, aLength) otDumpWarn(kLogRegionMem, aId, aBuf, aLength) #define otDumpInfoMem(aId, aBuf, aLength) otDumpInfo(kLogRegionMem, aId, aBuf, aLength) @@ -1197,7 +1197,7 @@ extern "C" { */ void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf, const size_t aLength); -#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL +#if OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL == 1 /** * This method converts the log level value into a string * @@ -1209,7 +1209,7 @@ void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void const char *otLogLevelToString(otLogLevel aLevel); #endif -#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION +#if OPENTHREAD_CONFIG_LOG_PREPEND_REGION == 1 /** * This method converts the log region value into a string * @@ -1221,9 +1221,9 @@ const char *otLogLevelToString(otLogLevel aLevel); const char *otLogRegionToString(otLogRegion aRegion); #endif -#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL +#if OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL == 1 -#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION +#if OPENTHREAD_CONFIG_LOG_PREPEND_REGION == 1 /** * Local/private macro to format the log message @@ -1256,7 +1256,7 @@ const char *otLogRegionToString(otLogRegion aRegion); #else // OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL -#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION +#if OPENTHREAD_CONFIG_LOG_PREPEND_REGION == 1 /** * Local/private macro to format the log message diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index d089d2790..1bb235d65 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -315,7 +315,9 @@ * Define to enable OpenThread API logging. * */ -#define OPENTHREAD_CONFIG_LOG_API +#ifndef OPENTHREAD_CONFIG_LOG_API +#define OPENTHREAD_CONFIG_LOG_API 1 +#endif // OPENTHREAD_CONFIG_LOG_API /** * @def OPENTHREAD_CONFIG_LOG_MLE @@ -323,7 +325,9 @@ * Define to enable MLE logging. * */ -#define OPENTHREAD_CONFIG_LOG_MLE +#ifndef OPENTHREAD_CONFIG_LOG_MLE +#define OPENTHREAD_CONFIG_LOG_MLE 1 +#endif // OPENTHREAD_CONFIG_LOG_MLE /** * @def OPENTHREAD_CONFIG_LOG_ARP @@ -331,7 +335,9 @@ * Define to enable EID-to-RLOC map logging. * */ -#define OPENTHREAD_CONFIG_LOG_ARP +#ifndef OPENTHREAD_CONFIG_LOG_ARP +#define OPENTHREAD_CONFIG_LOG_ARP 1 +#endif // OPENTHREAD_CONFIG_LOG_ARP /** * @def OPENTHREAD_CONFIG_LOG_NETDATA @@ -339,7 +345,9 @@ * Define to enable Network Data logging. * */ -#define OPENTHREAD_CONFIG_LOG_NETDATA +#ifndef OPENTHREAD_CONFIG_LOG_NETDATA +#define OPENTHREAD_CONFIG_LOG_NETDATA 1 +#endif // OPENTHREAD_CONFIG_LOG_NETDATA /** * @def OPENTHREAD_CONFIG_LOG_ICMP @@ -347,7 +355,9 @@ * Define to enable ICMPv6 logging. * */ -#define OPENTHREAD_CONFIG_LOG_ICMP +#ifndef OPENTHREAD_CONFIG_LOG_ICMP +#define OPENTHREAD_CONFIG_LOG_ICMP 1 +#endif // OPENTHREAD_CONFIG_LOG_ICMP /** * @def OPENTHREAD_CONFIG_LOG_IP6 @@ -355,7 +365,9 @@ * Define to enable IPv6 logging. * */ -#define OPENTHREAD_CONFIG_LOG_IP6 +#ifndef OPENTHREAD_CONFIG_LOG_IP6 +#define OPENTHREAD_CONFIG_LOG_IP6 1 +#endif // OPENTHREAD_CONFIG_LOG_IP6 /** * @def OPENTHREAD_CONFIG_LOG_MAC @@ -363,7 +375,9 @@ * Define to enable IEEE 802.15.4 MAC logging. * */ -#define OPENTHREAD_CONFIG_LOG_MAC +#ifndef OPENTHREAD_CONFIG_LOG_MAC +#define OPENTHREAD_CONFIG_LOG_MAC 1 +#endif // OPENTHREAD_CONFIG_LOG_MAC /** * @def OPENTHREAD_CONFIG_LOG_MEM @@ -371,7 +385,9 @@ * Define to enable memory logging. * */ -#define OPENTHREAD_CONFIG_LOG_MEM +#ifndef OPENTHREAD_CONFIG_LOG_MEM +#define OPENTHREAD_CONFIG_LOG_MEM 1 +#endif // OPENTHREAD_CONFIG_LOG_MEM /** * @def OPENTHREAD_CONFIG_LOG_NETDIAG @@ -379,7 +395,9 @@ * Define to enable network diagnostic logging. * */ -#define OPENTHREAD_CONFIG_LOG_NETDIAG +#ifndef OPENTHREAD_CONFIG_LOG_NETDIAG +#define OPENTHREAD_CONFIG_LOG_NETDIAG 1 +#endif // OPENTHREAD_CONFIG_LOG_NETDIAG /** * @def OPENTHREAD_CONFIG_LOG_PLATFORM @@ -387,7 +405,9 @@ * Define to enable platform region logging. * */ -//#define OPENTHREAD_CONFIG_LOG_PLATFORM +#ifndef OPENTHREAD_CONFIG_LOG_PLATFORM +#define OPENTHREAD_CONFIG_LOG_PLATFORM 0 +#endif // OPENTHREAD_CONFIG_LOG_PLATFORM /** * @def OPENTHREAD_CONFIG_LOG_PREPREND_LEVEL @@ -395,7 +415,9 @@ * Define to prepend the log level to all log messages * */ -#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL +#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL +#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 +#endif // OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL /** * @def OPENTHREAD_CONFIG_LOG_PREPREND_REGION @@ -403,7 +425,9 @@ * Define to prepend the log region to all log messages * */ -#define OPENTHREAD_CONFIG_LOG_PREPEND_REGION +#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_REGION +#define OPENTHREAD_CONFIG_LOG_PREPEND_REGION 1 +#endif // OPENTHREAD_CONFIG_LOG_PREPEND_REGION /** * @def OPENTHREAD_CONFIG_LOG_SUFFIX