picoco/buzzer/log.c
2025-03-03 15:36:32 +01:00

28 lines
471 B
C

#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "log.h"
void debug(const char *format, ...) {
#ifdef DEBUG
if (format == NULL) {
return;
}
time_t now;
time(&now);
char time_str[26];
ctime_r(&now, time_str);
time_str[24] = '\0';
fprintf(stdout, "[DEBUG] [%s] ", time_str);
va_list args;
va_start(args, format);
vfprintf(stdout, format, args);
va_end(args);
fprintf(stdout, "\n");
#endif
}