@@ -52,7 +52,7 @@ uint32_t MurmurHash(const void * key)
52
52
53
53
if (hash == 0 )
54
54
{
55
- ESP_LOGW ( " Tracing " , " MurmurHash resulted in a hash value of 0" );
55
+ ChipLogError (DeviceLayer , " MurmurHash resulted in a hash value of 0" );
56
56
}
57
57
58
58
return hash;
@@ -63,18 +63,23 @@ constexpr size_t kPermitListMaxSize = CONFIG_MAX_PERMIT_LIST_SIZE;
63
63
using HashValue = uint32_t ;
64
64
using namespace Utils ;
65
65
66
- // Only traces with scope in gPermitList are allowed.
67
- // Used for MATTER_TRACE_SCOPE()
66
+ /*
67
+ * gPermitList will allow the following traces to be stored in the storage instance while other traces are skipped.
68
+ * Only traces with scope in gPermitList are allowed.
69
+ * Used for MATTER_TRACE_SCOPE()
70
+ */
68
71
HashValue gPermitList [kPermitListMaxSize ] = { MurmurHash (" PASESession" ),
69
72
MurmurHash (" CASESession" ),
70
73
MurmurHash (" NetworkCommissioning" ),
71
74
MurmurHash (" GeneralCommissioning" ),
72
75
MurmurHash (" OperationalCredentials" ),
73
76
MurmurHash (" CASEServer" ),
74
- MurmurHash (" Fabric" ) }; // namespace
77
+ MurmurHash (" Fabric" ) };
75
78
76
- // All traces with value from gSkipList are skipped.
77
- // Used for MATTER_TRACE_INSTANT()
79
+ /*
80
+ * gSkipList will skip the following traces from being stored in the storage instance while other traces are stored.
81
+ * Used for MATTER_TRACE_INSTANT()
82
+ */
78
83
HashValue gSkipList [kPermitListMaxSize ] = {
79
84
MurmurHash (" Resolver" ),
80
85
};
@@ -111,14 +116,8 @@ void ESP32Diagnostics::LogMetricEvent(const MetricEvent & event)
111
116
switch (event.ValueType ())
112
117
{
113
118
case ValueType::kInt32 : {
114
- ChipLogProgress (DeviceLayer, " The value of %s is %" PRId32, event.key (), event.ValueInt32 ());
115
-
116
- // Allocate buffers for the diagnostic entry
117
- char labelBuffer[kMaxStringValueSize ];
118
- strncpy (labelBuffer, event.key (), kMaxStringValueSize );
119
- labelBuffer[kMaxStringValueSize - 1 ] = ' \0 ' ;
120
-
121
- DiagnosticEntry entry = { .label = labelBuffer,
119
+ ChipLogDetail (DeviceLayer, " The value of %s is %" PRId32, event.key (), event.ValueInt32 ());
120
+ DiagnosticEntry entry = { .label = const_cast <char *>(event.key ()),
122
121
.intValue = event.ValueInt32 (),
123
122
.type = Diagnostics::ValueType::kSignedInteger ,
124
123
.timestamp = esp_log_timestamp () };
@@ -127,14 +126,8 @@ void ESP32Diagnostics::LogMetricEvent(const MetricEvent & event)
127
126
break ;
128
127
129
128
case ValueType::kUInt32 : {
130
- ChipLogProgress (DeviceLayer, " The value of %s is %" PRId32, event.key (), event.ValueUInt32 ());
131
-
132
- // Allocate buffers for the diagnostic entry
133
- char labelBuffer[kMaxStringValueSize ];
134
- strncpy (labelBuffer, event.key (), kMaxStringValueSize );
135
- labelBuffer[kMaxStringValueSize - 1 ] = ' \0 ' ;
136
-
137
- DiagnosticEntry entry = { .label = labelBuffer,
129
+ ChipLogDetail (DeviceLayer, " The value of %s is %" PRId32, event.key (), event.ValueUInt32 ());
130
+ DiagnosticEntry entry = { .label = const_cast <char *>(event.key ()),
138
131
.uintValue = event.ValueUInt32 (),
139
132
.type = Diagnostics::ValueType::kUnsignedInteger ,
140
133
.timestamp = esp_log_timestamp () };
@@ -143,15 +136,15 @@ void ESP32Diagnostics::LogMetricEvent(const MetricEvent & event)
143
136
break ;
144
137
145
138
case ValueType::kChipErrorCode :
146
- ChipLogProgress (DeviceLayer, " The value of %s is error with code %lu " , event.key (), event.ValueErrorCode ());
139
+ ChipLogDetail (DeviceLayer, " The value of %s is error with code %lu " , event.key (), event.ValueErrorCode ());
147
140
break ;
148
141
149
142
case ValueType::kUndefined :
150
- ChipLogProgress (DeviceLayer, " The value of %s is undefined" , event.key ());
143
+ ChipLogDetail (DeviceLayer, " The value of %s is undefined" , event.key ());
151
144
break ;
152
145
153
146
default :
154
- ChipLogProgress (DeviceLayer, " The value of %s is of an UNKNOWN TYPE" , event.key ());
147
+ ChipLogDetail (DeviceLayer, " The value of %s is of an UNKNOWN TYPE" , event.key ());
155
148
break ;
156
149
}
157
150
}
@@ -180,18 +173,9 @@ CHIP_ERROR ESP32Diagnostics::StoreDiagnostics(const char * label, const char * g
180
173
VerifyOrReturnError (mStorageInstance != nullptr , CHIP_ERROR_INCORRECT_STATE,
181
174
ChipLogError (DeviceLayer, " Diagnostic Storage Instance cannot be NULL" ));
182
175
183
- // Allocate buffers for the diagnostic entry
184
- char labelBuffer[kMaxStringValueSize ];
185
- strncpy (labelBuffer, label, kMaxStringValueSize );
186
- labelBuffer[kMaxStringValueSize - 1 ] = ' \0 ' ;
187
-
188
- char groupBuffer[kMaxStringValueSize ];
189
- strncpy (groupBuffer, group, kMaxStringValueSize );
190
- groupBuffer[kMaxStringValueSize - 1 ] = ' \0 ' ;
191
-
192
176
// Create diagnostic entry
193
- DiagnosticEntry entry = { .label = labelBuffer ,
194
- .stringValue = groupBuffer ,
177
+ DiagnosticEntry entry = { .label = const_cast < char *>(label) ,
178
+ .stringValue = const_cast < char *>(group) ,
195
179
.type = Diagnostics::ValueType::kCharString ,
196
180
.timestamp = esp_log_timestamp () };
197
181
0 commit comments