@@ -102,32 +102,33 @@ void ESP32Diagnostics::LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo & info) {}
102
102
void ESP32Diagnostics::LogMetricEvent (const MetricEvent & event)
103
103
{
104
104
CHIP_ERROR err = CHIP_NO_ERROR;
105
+ VerifyOrReturn (mStorageInstance != nullptr , ChipLogError (DeviceLayer, " Diagnostic Storage Instance cannot be NULL" ));
105
106
switch (event.ValueType ())
106
107
{
107
108
case ValueType::kInt32 : {
108
- ESP_LOGI ( " mtr " , " The value of %s is %ld " , event.key (), event.ValueInt32 ());
109
+ ChipLogProgress (DeviceLayer , " The value of %s is %" PRId32 , event.key (), event.ValueInt32 ());
109
110
Diagnostic<int32_t > metric (event.key (), event.ValueInt32 (), esp_log_timestamp ());
110
- err = mStorageInstance . Store (metric);
111
+ err = mStorageInstance -> Store (metric);
111
112
}
112
113
break ;
113
114
114
115
case ValueType::kUInt32 : {
115
- ESP_LOGI ( " mtr " , " The value of %s is %lu " , event.key (), event.ValueUInt32 ());
116
+ ChipLogProgress (DeviceLayer , " The value of %s is %" PRId32 , event.key (), event.ValueUInt32 ());
116
117
Diagnostic<uint32_t > metric (event.key (), event.ValueUInt32 (), esp_log_timestamp ());
117
- err = mStorageInstance . Store (metric);
118
+ err = mStorageInstance -> Store (metric);
118
119
}
119
120
break ;
120
121
121
122
case ValueType::kChipErrorCode :
122
- ESP_LOGI ( " mtr " , " The value of %s is error with code %lu " , event.key (), event.ValueErrorCode ());
123
+ ChipLogProgress (DeviceLayer , " The value of %s is error with code %lu " , event.key (), event.ValueErrorCode ());
123
124
break ;
124
125
125
126
case ValueType::kUndefined :
126
- ESP_LOGI ( " mtr " , " The value of %s is undefined" , event.key ());
127
+ ChipLogProgress (DeviceLayer , " The value of %s is undefined" , event.key ());
127
128
break ;
128
129
129
130
default :
130
- ESP_LOGI ( " mtr " , " The value of %s is of an UNKNOWN TYPE" , event.key ());
131
+ ChipLogProgress (DeviceLayer , " The value of %s is of an UNKNOWN TYPE" , event.key ());
131
132
break ;
132
133
}
133
134
@@ -136,14 +137,16 @@ void ESP32Diagnostics::LogMetricEvent(const MetricEvent & event)
136
137
137
138
void ESP32Diagnostics::TraceCounter (const char * label)
138
139
{
139
- ESPDiagnosticCounter::GetInstance (label).ReportMetrics (label, mStorageInstance );
140
+ CHIP_ERROR err = ESPDiagnosticCounter::GetInstance (label).ReportMetrics (label, mStorageInstance );
141
+ VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (DeviceLayer, " Failed to store Counter Diagnostic data" ));
140
142
}
141
143
142
144
void ESP32Diagnostics::TraceBegin (const char * label, const char * group)
143
145
{
144
146
if (IsPermitted (group))
145
147
{
146
- StoreDiagnostics (label, group);
148
+ CHIP_ERROR err = StoreDiagnostics (label, group);
149
+ VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (DeviceLayer, " Failed to store Trace Diagnostic data" ));
147
150
}
148
151
}
149
152
@@ -153,15 +156,18 @@ void ESP32Diagnostics::TraceInstant(const char * label, const char * value)
153
156
{
154
157
if (!IsPermitted (value))
155
158
{
156
- StoreDiagnostics (label, value);
159
+ CHIP_ERROR err = StoreDiagnostics (label, value);
160
+ VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (DeviceLayer, " Failed to store Trace Diagnostic data" ));
157
161
}
158
162
}
159
163
160
- void ESP32Diagnostics::StoreDiagnostics (const char * label, const char * group)
164
+ CHIP_ERROR ESP32Diagnostics::StoreDiagnostics (const char * label, const char * group)
161
165
{
166
+ CHIP_ERROR err = CHIP_NO_ERROR;
167
+ VerifyOrReturnError (mStorageInstance != nullptr , err, ChipLogError (DeviceLayer, " Diagnostic Storage Instance cannot be NULL" ));
162
168
Diagnostic<const char *> trace (label, group, esp_log_timestamp ());
163
- VerifyOrReturn ( mStorageInstance . Store (trace) == CHIP_NO_ERROR,
164
- ChipLogError (DeviceLayer, " Failed to store Trace Diagnostic data " )) ;
169
+ err = mStorageInstance -> Store (trace);
170
+ return err ;
165
171
}
166
172
167
173
} // namespace Diagnostics
0 commit comments