Skip to content

Commit

Permalink
Make node id logging optional
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardmgh committed Mar 13, 2024
1 parent 01c3974 commit 47cc338
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,16 @@
#define CHIP_CONFIG_ENABLE_CONDITION_LOGGING 0
#endif // CHIP_CONFIG_ENABLE_CONDITION_LOGGING

/**
* @def CHIP_EXCHANGE_NODE_ID_LOGGING
*
* @brief
* If asserted (1), enable logging of node IDs in exchange context.
*/
#ifndef CHIP_EXCHANGE_NODE_ID_LOGGING
#define CHIP_EXCHANGE_NODE_ID_LOGGING 0
#endif // CHIP_EXCHANGE_NODE_ID_LOGGING

/**
* @def CHIP_CONFIG_TEST
*
Expand Down
8 changes: 7 additions & 1 deletion src/lib/support/logging/TextOnlyLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,15 @@ using LogRedirectCallback_t = void (*)(const char * module, uint8_t category, co
*/
#define ChipLogFormatExchangeId "%u%c"
#define ChipLogValueExchangeId(id, isInitiator) id, ((isInitiator) ? 'i' : 'r')
#define ChipLogFormatExchange ChipLogFormatExchangeId " " ChipLogFormatScopedNodeId

#if CHIP_EXCHANGE_NODE_ID_LOGGING
#define ChipLogFormatExchange ChipLogFormatExchangeId " with Node: " ChipLogFormatScopedNodeId
#define ChipLogValueExchange(ec) ChipLogValueExchangeId((ec)->GetExchangeId(), (ec)->IsInitiator()), \
ChipLogValueScopedNodeId((ec)->HasSessionHandle() ? (ec)->GetSessionHandle()->GetPeer() : ScopedNodeId())
#else // CHIP_EXCHANGE_NODE_ID_LOGGING
#define ChipLogFormatExchange ChipLogFormatExchangeId
#define ChipLogValueExchange(ec) ChipLogValueExchangeId((ec)->GetExchangeId(), (ec)->IsInitiator())
#endif // CHIP_EXCHANGE_NODE_ID_LOGGING

#define ChipLogValueExchangeIdFromSentHeader(payloadHeader) \
ChipLogValueExchangeId((payloadHeader).GetExchangeID(), (payloadHeader).IsInitiator())
Expand Down

0 comments on commit 47cc338

Please sign in to comment.