Files
OptoTest/OpticalChannelTester/Log.cpp

25 lines
781 B
C++

#include "Log.h"
#include "Config.h"
#include <stdarg.h>
#include <string.h>
namespace Log {
void event(const char *component, const char *message) {
if (!SERIAL_ACTION_LOG) return;
if (SERIAL_MINIMAL_LOG && strcmp(component, "INPUT") && strcmp(component, "UI") &&
strcmp(component, "CONFIG") && strcmp(component, "RESULT") && strcmp(component, "ESP-NOW")) return;
if (SERIAL_LOG_TIMESTAMPS) Serial.printf("[%10lu][%-8s] %s\n", millis(), component, message);
else Serial.printf("[%-8s] %s\n", component, message);
}
void printf(const char *component, const char *format, ...) {
if (!SERIAL_ACTION_LOG) return;
char text[192];
va_list args;
va_start(args, format);
vsnprintf(text, sizeof(text), format, args);
va_end(args);
event(component, text);
}
}