Reintroducing wallclock

This commit is contained in:
jpirnay
2026-04-08 10:57:51 +02:00
parent 93f285d296
commit 93659502f7
+10 -2
View File
@@ -1,6 +1,7 @@
#include "Logging.h"
#include <HalClock.h>
#include <algorithm>
#include <string>
@@ -40,10 +41,17 @@ void logPrintf(const char* level, const char* origin, const char* format, ...) {
va_start(args, format);
char buf[MAX_ENTRY_LEN];
char* c = buf;
// add timestamp, level and origin
// add timestamp, wall clock, level and origin
{
unsigned long ms = millis();
int len = snprintf(c, sizeof(buf), "[%lu] [%s] [%s] ", ms, level, origin);
char wallClock[12];
HalClock::formatLogTime(wallClock, sizeof(wallClock));
int len;
if (wallClock[0] != '\0') {
len = snprintf(c, sizeof(buf), "[%lu %s] [%s] [%s] ", ms, wallClock, level, origin);
} else {
len = snprintf(c, sizeof(buf), "[%lu] [%s] [%s] ", ms, level, origin);
}
// error while writing => return
if (len < 0) {
va_end(args);