This repository has been archived on 2020-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
gnoemoe/src/debug.c

40 lines
657 B
C

#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
int dbgLevel = 0;
void
debug_msg(int level, char *line, ...) {
struct tm *timet;
time_t timer;
va_list args;
FILE *f;
if (dbgLevel >= level) {
va_start(args, line);
timer = time(0);
timet = localtime(&timer);
if (level == 0) {
f = stdout;
} else {
f = stderr;
}
fprintf(f, "[%02d:%02d:%02d] # ", timet->tm_hour, timet->tm_min,
timet->tm_sec);
vfprintf(f, line, args);
printf("\n");
va_end(args);
}
}
void
debug_set_level(int level) {
dbgLevel = level;
}