Skip to content

Commit c18ecc1

Browse files
committed
SleepTracing: don't spam logs if no lock is held
1 parent 8837069 commit c18ecc1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

platform/source/mbed_power_mgmt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static sleep_statistic_t *sleep_tracker_add(const char *const filename)
138138

139139
static void sleep_tracker_print_stats(void)
140140
{
141-
mbed_error_printf("Sleep locks held:\r\n");
141+
bool once = true;
142142
for (int i = 0; i < STATISTIC_COUNT; ++i) {
143143
if (sleep_stats[i].count == 0) {
144144
continue;
@@ -148,6 +148,11 @@ static void sleep_tracker_print_stats(void)
148148
return;
149149
}
150150

151+
if (once) {
152+
mbed_error_printf("Sleep locks held:\r\n");
153+
once = false;
154+
}
155+
151156
mbed_error_printf("[id: %s, count: %u]\r\n", sleep_stats[i].identifier,
152157
sleep_stats[i].count);
153158
}

0 commit comments

Comments
 (0)