Filename changed

This commit is contained in:
Jesse van den Kieboom 2005-11-06 16:20:55 +00:00
parent b6e8f65fa3
commit 3c9fb56df5
1 changed files with 44 additions and 0 deletions

44
src/gm-debug.c Normal file
View File

@ -0,0 +1,44 @@
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
static gint debug_level = DEBUG_ALWAYS;
static void
gm_debug_msg_real(FILE *f, struct tm *timet, gchar *line, va_list args) {
fprintf(f, "[%02d:%02d:%02d] # ", timet->tm_hour, timet->tm_min,
timet->tm_sec);
vfprintf(f, line, args);
fprintf(f, "\n");
}
void
gm_debug_msg(gint level, gchar *line, ...) {
struct tm *timet;
time_t timer;
va_list args;
if (debug_level | level == debug_level) {
va_start(args, line);
timer = time(0);
timet = localtime(&timer);
if (level & DEBUG_ALWAYS) {
gm_debug_msg_real(stdout, timet, line, args);
}
if (level & DEBUG_ALWAYS != level) {
gm_debug_msg_real(stderr, timet, line, args);
}
va_end(args);
}
}
void
debug_set_level(gint level) {
debug_level = level;
}