25
25
#include < tracing/metric_event.h>
26
26
#include < tracing/registry.h>
27
27
28
+ /*
29
+ * Set this to MTR_LOG_DEBUG(__VA_ARGS__) to enable logging noisy debug logging for metrics events processing
30
+ */
31
+ #define MTR_METRICS_LOG_DEBUG (...)
32
+
28
33
using MetricEvent = chip::Tracing::MetricEvent;
29
34
30
35
@implementation MTRMetricData {
@@ -74,7 +79,8 @@ - (instancetype)initWithMetricEvent:(const MetricEvent &)event
74
79
case ValueType::kUndefined :
75
80
break ;
76
81
}
77
- MTR_LOG_DEBUG (" Initializing metric event data %s, type: %d, with time point %llu" , event.key (), _type, _timePoint.count ());
82
+
83
+ MTR_METRICS_LOG_DEBUG (" Initializing metric event data %s, type: %d, with time point %llu" , event.key (), _type, _timePoint.count ());
78
84
return self;
79
85
}
80
86
@@ -83,7 +89,7 @@ - (void)setDurationFromMetricData:(MTRMetricData *)fromData
83
89
auto duration = _timePoint - fromData->_timePoint ;
84
90
_duration = [NSNumber numberWithDouble: double (duration.count ()) / USEC_PER_SEC];
85
91
86
- MTR_LOG_DEBUG (" Calculating duration for Matter metric with type %d, from type %d, (%llu - %llu) = %llu us (%llu s)" ,
92
+ MTR_METRICS_LOG_DEBUG (" Calculating duration for Matter metric with type %d, from type %d, (%llu - %llu) = %llu us (%llu s)" ,
87
93
_type, fromData->_type , _timePoint.count (), fromData->_timePoint .count (), duration.count (), [_duration unsignedLongLongValue ]);
88
94
}
89
95
@@ -201,19 +207,19 @@ - (void)handleMetricEvent:(MetricEvent)event
201
207
using ValueType = MetricEvent::Value::Type;
202
208
switch (event.ValueType ()) {
203
209
case ValueType::kInt32 :
204
- MTR_LOG_DEBUG (" Received metric event, key: %s, type: %d, value: %d" , event.key (), static_cast <int >(event.type ()), event.ValueInt32 ());
210
+ MTR_METRICS_LOG_DEBUG (" Received metric event, key: %s, type: %d, value: %d" , event.key (), static_cast <int >(event.type ()), event.ValueInt32 ());
205
211
break ;
206
212
case ValueType::kUInt32 :
207
- MTR_LOG_DEBUG (" Received metric event, key: %s, type: %d, value: %u" , event.key (), static_cast <int >(event.type ()), event.ValueUInt32 ());
213
+ MTR_METRICS_LOG_DEBUG (" Received metric event, key: %s, type: %d, value: %u" , event.key (), static_cast <int >(event.type ()), event.ValueUInt32 ());
208
214
break ;
209
215
case ValueType::kChipErrorCode :
210
- MTR_LOG_DEBUG (" Received metric event, key: %s, type: %d, error value: %u" , event.key (), static_cast <int >(event.type ()), event.ValueErrorCode ());
216
+ MTR_METRICS_LOG_DEBUG (" Received metric event, key: %s, type: %d, error value: %u" , event.key (), static_cast <int >(event.type ()), event.ValueErrorCode ());
211
217
break ;
212
218
case ValueType::kUndefined :
213
- MTR_LOG_DEBUG (" Received metric event, key: %s, type: %d, value: nil" , event.key (), static_cast <int >(event.type ()));
219
+ MTR_METRICS_LOG_DEBUG (" Received metric event, key: %s, type: %d, value: nil" , event.key (), static_cast <int >(event.type ()));
214
220
break ;
215
221
default :
216
- MTR_LOG_DEBUG (" Received metric event, key: %s, type: %d, unknown value" , event.key (), static_cast <int >(event.type ()));
222
+ MTR_METRICS_LOG_DEBUG (" Received metric event, key: %s, type: %d, unknown value" , event.key (), static_cast <int >(event.type ()));
217
223
return ;
218
224
}
219
225
0 commit comments