@@ -202,12 +202,28 @@ class TaskMonitor : public BaseComponent {
202
202
if (task_info.empty ()) {
203
203
return output;
204
204
}
205
- output = " | Task Name | CPU % | High Water Mark | Priority | Core ID |\n "
206
- " | ---------------- | ----- | --------------- | -------- | ------- |\n " ;
205
+ static constexpr int task_name_header_min_width = 9 ; // length of "Task Name"
206
+ static constexpr int task_name_max_width = CONFIG_FREERTOS_MAX_TASK_NAME_LEN;
207
+ static constexpr int task_name_width =
208
+ std::max (task_name_header_min_width, task_name_max_width);
209
+ #if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
210
+ output = fmt::format (" | {1: ^{0}.{0}s} | CPU % | High Water Mark | Priority | Core ID |\n "
211
+ " | {2:->{0}} | ----- | --------------- | -------- | ------- |\n " ,
212
+ task_name_width, " Task Name" , " " );
213
+ for (const auto &t : task_info) {
214
+ output += fmt::format (" | {1: >{0}.{0}s} | {2: >3} % | {3: >13} B | {4: >8} | {5: >7} |\n " ,
215
+ task_name_width, t.name , t.cpu_percent , t.high_water_mark , t.priority ,
216
+ t.core_id );
217
+ }
218
+ #else
219
+ output = fmt::format (" | {1: ^{0}.{0}s} | CPU % | High Water Mark | Priority |\n "
220
+ " | {2:->{0}} | ----- | --------------- | -------- |\n " ,
221
+ task_name_width, " Task Name" , " " );
207
222
for (const auto &t : task_info) {
208
- output += fmt::format (" | {: >16.16s} | {: >3} % | {: >13} B | {: >8} | {: >7} | \n " , t. name ,
209
- t. cpu_percent , t.high_water_mark , t.priority , t.core_id );
223
+ output += fmt::format (" | {1 : >{0}.{0}s} | {2 : >3} % | {3 : >13} B | {4 : >8} |\n " ,
224
+ task_name_width, t. name , t.cpu_percent , t.high_water_mark , t.priority );
210
225
}
226
+ #endif
211
227
return output;
212
228
}
213
229
@@ -236,7 +252,12 @@ template <> struct fmt::formatter<espp::TaskMonitor::TaskInfo> {
236
252
template <typename FormatContext>
237
253
auto format (const espp::TaskMonitor::TaskInfo &t, FormatContext &ctx) {
238
254
return fmt::format_to (
255
+ #if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
239
256
ctx.out (), " TaskInfo(name={}, cpu_percent={}, high_water_mark={}, priority={}, core_id={})" ,
240
257
t.name , t.cpu_percent , t.high_water_mark , t.priority , t.core_id );
258
+ #else
259
+ ctx.out (), " TaskInfo(name={}, cpu_percent={}, high_water_mark={}, priority={})" , t.name ,
260
+ t.cpu_percent , t.high_water_mark , t.priority );
261
+ #endif
241
262
}
242
263
};
0 commit comments