Skip to content

Commit 8c60daa

Browse files
authored
Merge pull request #33 from leonardmgh/add-nodeid-logging
Add loogging of nodeID patch
2 parents a70d65e + 21ebd5b commit 8c60daa

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From a0ba59275c2094028323ec6c4a4135ab8795b158 Mon Sep 17 00:00:00 2001
2+
From: leonardmgh <leonard@hansen-net.eu>
3+
Date: Tue, 19 Mar 2024 11:25:07 +0100
4+
Subject: [PATCH] Log node ID in exchanges (#32550)
5+
6+
* Log nodeID in exchange context
7+
8+
* Update comments
9+
10+
* Use ChipLogValueScopedNodeId with ScopedNodeId instead of SubjectDescriptor
11+
12+
* Make node id logging optional
13+
14+
* Restyled by whitespace
15+
16+
* Restyled by clang-format
17+
18+
---------
19+
20+
Co-authored-by: Restyled.io <commits@restyled.io>
21+
---
22+
src/lib/core/CHIPConfig.h | 10 ++++++++++
23+
src/lib/support/logging/TextOnlyLogging.h | 14 +++++++++++---
24+
2 files changed, 21 insertions(+), 3 deletions(-)
25+
26+
diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h
27+
index 2de6a662ee..558e0ee08e 100644
28+
--- a/src/lib/core/CHIPConfig.h
29+
+++ b/src/lib/core/CHIPConfig.h
30+
@@ -461,6 +461,16 @@
31+
#define CHIP_CONFIG_ENABLE_CONDITION_LOGGING 0
32+
#endif // CHIP_CONFIG_ENABLE_CONDITION_LOGGING
33+
34+
+/**
35+
+ * @def CHIP_EXCHANGE_NODE_ID_LOGGING
36+
+ *
37+
+ * @brief
38+
+ * If asserted (1), enable logging of node IDs in exchange context.
39+
+ */
40+
+#ifndef CHIP_EXCHANGE_NODE_ID_LOGGING
41+
+#define CHIP_EXCHANGE_NODE_ID_LOGGING 1
42+
+#endif // CHIP_EXCHANGE_NODE_ID_LOGGING
43+
+
44+
/**
45+
* @def CHIP_CONFIG_TEST
46+
*
47+
diff --git a/src/lib/support/logging/TextOnlyLogging.h b/src/lib/support/logging/TextOnlyLogging.h
48+
index d6b22f7c6c..b0abef9d00 100644
49+
--- a/src/lib/support/logging/TextOnlyLogging.h
50+
+++ b/src/lib/support/logging/TextOnlyLogging.h
51+
@@ -268,16 +268,24 @@ using LogRedirectCallback_t = void (*)(const char * module, uint8_t category, co
52+
#define ChipLogValueMEI(aValue) static_cast<uint16_t>(aValue >> 16), static_cast<uint16_t>(aValue)
53+
54+
/**
55+
- * Logging helpers for exchanges. For now just log the exchange id and whether
56+
- * it's an initiator or responder, but eventually we may want to log the peer
57+
- * node id as well (especially for the responder case). Some callsites only
58+
+ * Logging helpers for exchanges. Log the exchange id, whether
59+
+ * it's an initiator or responder and the scoped node. Some callsites only
60+
* have the exchange id and initiator/responder boolean, not an actual exchange,
61+
* so we want to have a helper for that case too.
62+
*/
63+
#define ChipLogFormatExchangeId "%u%c"
64+
#define ChipLogValueExchangeId(id, isInitiator) id, ((isInitiator) ? 'i' : 'r')
65+
+
66+
+#if CHIP_EXCHANGE_NODE_ID_LOGGING
67+
+#define ChipLogFormatExchange ChipLogFormatExchangeId " with Node: " ChipLogFormatScopedNodeId
68+
+#define ChipLogValueExchange(ec) \
69+
+ ChipLogValueExchangeId((ec)->GetExchangeId(), (ec)->IsInitiator()), \
70+
+ ChipLogValueScopedNodeId((ec)->HasSessionHandle() ? (ec)->GetSessionHandle()->GetPeer() : ScopedNodeId())
71+
+#else // CHIP_EXCHANGE_NODE_ID_LOGGING
72+
#define ChipLogFormatExchange ChipLogFormatExchangeId
73+
#define ChipLogValueExchange(ec) ChipLogValueExchangeId((ec)->GetExchangeId(), (ec)->IsInitiator())
74+
+#endif // CHIP_EXCHANGE_NODE_ID_LOGGING
75+
+
76+
#define ChipLogValueExchangeIdFromSentHeader(payloadHeader) \
77+
ChipLogValueExchangeId((payloadHeader).GetExchangeID(), (payloadHeader).IsInitiator())
78+
// A received header's initiator boolean is the inverse of the exchange's.
79+
--
80+
2.39.3 (Apple Git-146)
81+

0 commit comments

Comments
 (0)