8 #include "debug_printf.h"
10 #define RED "\x1b[31;01m"
11 #define DARKRED "\x1b[31;06m"
12 #define RESET "\x1b[0m"
13 #define GREEN "\x1b[32;06m"
14 #define YELLOW "\x1b[33;06m"
17 /* Compiler does not like it when I initialize this to stdout, complaints about
18 * not being constant. stoud is a macro..
23 void debug_set_output(FILE *fp
)
28 void debug_set_level(DebugLevel dl
)
30 debug_level
= (dl
<0)?DEBUG_NO_OUTPUT
:((dl
> DEBUG_INFO
)?DEBUG_INFO
:dl
);
34 void debug_printf_real(DebugLevel dp
, const char *file
,const int line
,const char *function
, const char *format
,...)
39 time_t ts
= time(NULL
);
44 va_start(arglist
,format
);
46 /* Windows has no thread-safe localtime_r function, so ignore it for now */
48 localtime_r(&ts
, &tm
);
49 strftime(buffer
, 32, "%d/%m/%y %T",&tm
);
56 fprintf(out
,"%s: "GREEN
"INFO:"RESET
" %s %s():#%d:\t",buffer
,file
,function
,line
);
58 else if(dp
== DEBUG_WARNING
)
60 fprintf(out
,"%s: "YELLOW
"WARNING:"RESET
" %s %s():#%i:\t",buffer
,file
,function
,line
);
64 fprintf(out
,"%s: "DARKRED
"ERROR:"RESET
" %s %s():#%i:\t",buffer
,file
,function
,line
);
66 vfprintf(out
,format
, arglist
);
67 if(format
[strlen(format
)-1] != '\n')