DDraceNetwork Docs
log.h
Go to the documentation of this file.
1#ifndef BASE_LOG_H
2#define BASE_LOG_H
3
4#include <cstdarg>
5#include <cstdint>
6
7#ifdef __GNUC__
8#define GNUC_ATTRIBUTE(x) __attribute__(x)
9#else
10#define GNUC_ATTRIBUTE(x)
11#endif
12
13enum LEVEL : char
14{
20};
21
23{
24 uint8_t r;
25 uint8_t g;
26 uint8_t b;
27};
28
29#define log_error(sys, ...) log_log(LEVEL_ERROR, sys, __VA_ARGS__)
30#define log_warn(sys, ...) log_log(LEVEL_WARN, sys, __VA_ARGS__)
31#define log_info(sys, ...) log_log(LEVEL_INFO, sys, __VA_ARGS__)
32#define log_debug(sys, ...) log_log(LEVEL_DEBUG, sys, __VA_ARGS__)
33#define log_trace(sys, ...) log_log(LEVEL_TRACE, sys, __VA_ARGS__)
34
35#define log_error_color(color, sys, ...) log_log_color(LEVEL_ERROR, color, sys, __VA_ARGS__)
36#define log_warn_color(color, sys, ...) log_log_color(LEVEL_WARN, color, sys, __VA_ARGS__)
37#define log_info_color(color, sys, ...) log_log_color(LEVEL_INFO, color, sys, __VA_ARGS__)
38#define log_debug_color(color, sys, ...) log_log_color(LEVEL_DEBUG, color, sys, __VA_ARGS__)
39#define log_trace_color(color, sys, ...) log_log_color(LEVEL_TRACE, color, sys, __VA_ARGS__)
40
56void log_log(LEVEL level, const char *sys, const char *fmt, ...)
57 GNUC_ATTRIBUTE((format(printf, 3, 4)));
58
69void log_log_color(LEVEL level, LOG_COLOR color, const char *sys, const char *fmt, ...)
70 GNUC_ATTRIBUTE((format(printf, 4, 5)));
71
82void log_log_v(LEVEL level, const char *sys, const char *fmt, va_list args)
83 GNUC_ATTRIBUTE((format(printf, 3, 0)));
84
96void log_log_color_v(LEVEL level, LOG_COLOR color, const char *sys, const char *fmt, va_list args)
97 GNUC_ATTRIBUTE((format(printf, 4, 0)));
98#endif // BASE_LOG_H
void log_log_v(LEVEL level, const char *sys, const char *fmt, va_list args)
Definition: log.cpp:118
void log_log_color_v(LEVEL level, LOG_COLOR color, const char *sys, const char *fmt, va_list args)
Definition: log.cpp:131
void log_log(LEVEL level, const char *sys, const char *fmt,...)
Definition: log.cpp:123
void log_log_color(LEVEL level, LOG_COLOR color, const char *sys, const char *fmt,...)
Definition: log.cpp:136
#define GNUC_ATTRIBUTE(x)
Definition: log.h:10
LEVEL
Definition: log.h:14
@ LEVEL_TRACE
Definition: log.h:19
@ LEVEL_DEBUG
Definition: log.h:18
@ LEVEL_ERROR
Definition: log.h:15
@ LEVEL_INFO
Definition: log.h:17
@ LEVEL_WARN
Definition: log.h:16
Definition: log.h:23
uint8_t b
Definition: log.h:26
uint8_t g
Definition: log.h:25
uint8_t r
Definition: log.h:24