-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_boii.h
63 lines (57 loc) · 1.89 KB
/
log_boii.h
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
#ifndef LOG_BOII
#define LOG_BOII
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Log levels.
*
* Use `log_level` properly :)
*
* References how to use log levels properly:
* https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
* https://betterstack.com/community/guides/logging/log-levels-explained/
*
*/
typedef enum log_level
{
LOG_TRACE,
LOG_DEBUG,
LOG_INFO,
LOG_WARN,
LOG_ERROR,
LOG_FATAL
} log_level;
#define log_trace(...) \
log_boii(LOG_TRACE, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define log_debug(...) \
log_boii(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define log_info(...) \
log_boii(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define log_warn(...) \
log_boii(LOG_WARN, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define log_error(...) \
log_boii(LOG_ERROR, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define log_fatal(...) \
log_boii(LOG_FATAL, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
/*
* Base function for all logging functions.
*
* Use `log_level` properly :)
*
* References how to use log levels properly:
* https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
* https://betterstack.com/community/guides/logging/log-levels-explained/
*
*/
void log_boii(log_level level,
const char* function,
const char* file,
int line,
const char* format_string,
...);
#ifdef __cplusplus
}
#endif
#endif