-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebug.c
More file actions
83 lines (68 loc) · 1.51 KB
/
Copy pathdebug.c
File metadata and controls
83 lines (68 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "debug.h"
#include "configuration.h"
#include <stdio.h>
#include <stdarg.h>
extern hacksdl_config_t config;
void sdterr_yellow () {
fprintf(stderr,"\033[1;33m");
}
void sdterr_red () {
fprintf(stderr,"\033[1;31m");
}
void sdterr_blue () {
fprintf(stderr,"\033[1;34m");
}
void sdterr_reset () {
fprintf(stderr,"\033[0m");
}
/*
HACKSDL_error: print error to stderr
*/
void HACKSDL_error_func(const char* func_name, char* format, ...)
{
va_list args;
sdterr_red();
fprintf(stderr,"[HACKSDL.error(%s)] ", func_name);
va_start(args, format);
vfprintf(stderr,format, args);
va_end(args);
fprintf(stderr,"\n");
sdterr_reset();
fflush(stderr);
}
/*
HACKSDL_info: print to stderr when verbose > 0
*/
void HACKSDL_info(char* format, ...)
{
va_list args;
if(config.verbose > 0)
{
sdterr_blue();
fprintf(stderr,"[HACKSDL.info] ");
va_start(args, format);
vfprintf(stderr,format, args);
va_end(args);
fprintf(stderr,"\n");
sdterr_reset();
fflush(stderr);
}
}
/*
HACKSDL_debug: print to stderr when verbose > 1
*/
void HACKSDL_debug_func(const char* func_name, char* format, ...)
{
va_list args;
if(config.verbose > 1)
{
sdterr_yellow();
fprintf(stderr,"[HACKSDL.debug(%s)] ", func_name);
va_start(args, format);
vfprintf(stderr,format, args);
va_end(args);
fprintf(stderr,"\n");
sdterr_reset();
fflush(stderr);
}
}