Reintroducing wallclock
This commit is contained in:
+10
-2
@@ -1,6 +1,7 @@
|
|||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
||||||
#include <HalClock.h>
|
#include <HalClock.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -40,10 +41,17 @@ void logPrintf(const char* level, const char* origin, const char* format, ...) {
|
|||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
char buf[MAX_ENTRY_LEN];
|
char buf[MAX_ENTRY_LEN];
|
||||||
char* c = buf;
|
char* c = buf;
|
||||||
// add timestamp, level and origin
|
// add timestamp, wall clock, level and origin
|
||||||
{
|
{
|
||||||
unsigned long ms = millis();
|
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
|
// error while writing => return
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|||||||
Reference in New Issue
Block a user