blob: 243e04bcdc347aacd264d06d29a39c7ffbda3d2c (
plain)
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
|
// public internal
#include "rodeo_types.h"
#include "rodeo.h"
// external
#include "SDL2/SDL.h"
static rodeo_log_function logging_function = NULL;
void
rodeo_log(
rodeo_logLevel_t loglevel,
const char *format,
...
)
{
rodeo_string_t formatted;
mrodeo_vargs_do(format)
{
formatted = rodeo_string_vargs_format(format, vargs);
}
switch(loglevel)
{
case rodeo_logLevel_info:
rodeo_string_prepend(
&formatted,
rodeo_string_create("[INFO]: ")
);
break;
case rodeo_logLevel_warning:
rodeo_string_prepend(
&formatted,
rodeo_string_create("\033[33m[WARN]:\033[0m ")
);
break;
case rodeo_logLevel_error:
rodeo_string_prepend(
&formatted,
rodeo_string_create("\033[31;1m[ERROR]:\033[0m ")
);
break;
}
rodeo_string_append(
&formatted,
rodeo_string_create("\n")
);
if(logging_function == NULL)
{
printf("%s", rodeo_string_to_constcstr(&formatted));
}
else
{
logging_function(formatted);
}
}
void
rodeo_log_function_set(rodeo_log_function rodeo_log_func)
{
logging_function = rodeo_log_func;
}
|