1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-09-25 01:54:34 +00:00
rk65c02/src/log.c

44 lines
583 B
C
Raw Normal View History

2018-03-21 15:22:29 +00:00
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
2018-03-21 15:22:29 +00:00
#include "log.h"
static const char *level_str[] = {
"",
"CRITICAL",
"ERROR",
"INFO",
"DEBUG",
"TRACE"
};
static uint8_t level = LOG_INFO;
void rk6502_loglevel_set(uint8_t l)
{
level = l;
}
void rk6502_log(uint8_t l, const char* fmt, ...)
{
va_list args;
struct timeval t;
gettimeofday(&t, NULL);
2018-03-21 15:22:29 +00:00
if (l > level)
return;
fprintf(stderr, "%ld %s:\t", (t.tv_sec * 1000000 + t.tv_usec),
level_str[l]);
2018-03-21 15:22:29 +00:00
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}