Skip to content

Commit 5317300

Browse files
Merge branch 'master' into Set-3-18-24
2 parents d663a09 + a0ba592 commit 5317300

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/lib/core/CHIPConfig.h

+10
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,16 @@
461461
#define CHIP_CONFIG_ENABLE_CONDITION_LOGGING 0
462462
#endif // CHIP_CONFIG_ENABLE_CONDITION_LOGGING
463463

464+
/**
465+
* @def CHIP_EXCHANGE_NODE_ID_LOGGING
466+
*
467+
* @brief
468+
* If asserted (1), enable logging of node IDs in exchange context.
469+
*/
470+
#ifndef CHIP_EXCHANGE_NODE_ID_LOGGING
471+
#define CHIP_EXCHANGE_NODE_ID_LOGGING 0
472+
#endif // CHIP_EXCHANGE_NODE_ID_LOGGING
473+
464474
/**
465475
* @def CHIP_CONFIG_TEST
466476
*

src/lib/support/logging/TextOnlyLogging.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,24 @@ using LogRedirectCallback_t = void (*)(const char * module, uint8_t category, co
268268
#define ChipLogValueMEI(aValue) static_cast<uint16_t>(aValue >> 16), static_cast<uint16_t>(aValue)
269269

270270
/**
271-
* Logging helpers for exchanges. For now just log the exchange id and whether
272-
* it's an initiator or responder, but eventually we may want to log the peer
273-
* node id as well (especially for the responder case). Some callsites only
271+
* Logging helpers for exchanges. Log the exchange id, whether
272+
* it's an initiator or responder and the scoped node. Some callsites only
274273
* have the exchange id and initiator/responder boolean, not an actual exchange,
275274
* so we want to have a helper for that case too.
276275
*/
277276
#define ChipLogFormatExchangeId "%u%c"
278277
#define ChipLogValueExchangeId(id, isInitiator) id, ((isInitiator) ? 'i' : 'r')
278+
279+
#if CHIP_EXCHANGE_NODE_ID_LOGGING
280+
#define ChipLogFormatExchange ChipLogFormatExchangeId " with Node: " ChipLogFormatScopedNodeId
281+
#define ChipLogValueExchange(ec) \
282+
ChipLogValueExchangeId((ec)->GetExchangeId(), (ec)->IsInitiator()), \
283+
ChipLogValueScopedNodeId((ec)->HasSessionHandle() ? (ec)->GetSessionHandle()->GetPeer() : ScopedNodeId())
284+
#else // CHIP_EXCHANGE_NODE_ID_LOGGING
279285
#define ChipLogFormatExchange ChipLogFormatExchangeId
280286
#define ChipLogValueExchange(ec) ChipLogValueExchangeId((ec)->GetExchangeId(), (ec)->IsInitiator())
287+
#endif // CHIP_EXCHANGE_NODE_ID_LOGGING
288+
281289
#define ChipLogValueExchangeIdFromSentHeader(payloadHeader) \
282290
ChipLogValueExchangeId((payloadHeader).GetExchangeID(), (payloadHeader).IsInitiator())
283291
// A received header's initiator boolean is the inverse of the exchange's.

0 commit comments

Comments
 (0)