42 #define __FILENAME__ \
43 (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
68 #define PRINT_FUNC (LOG_LEVEL > 3)
76 #define PRINT_FILE (LOG_LEVEL > 2)
111 #define COLOR(text, color, style) "\033[" #style ";" #color "m" text "\033[0m"
113 #define RED(text) COLOR(text, 31, 0)
114 #define GRN(text) COLOR(text, 32, 0)
115 #define YLW(text) COLOR(text, 33, 0)
116 #define PRL(text) COLOR(text, 35, 0)
117 #define CYN(text) COLOR(text, 36, 0)
129 #define log_d(message, ...) \
130 if (get_log_level() > 3) \
131 log_format(__stdoutp, CYN("dbg"), message __VA_OPT__(, ) __VA_ARGS__);
135 #define log_i(message, ...) \
136 if (get_log_level() > 2) \
137 log_format(__stdoutp, GRN("inf"), message __VA_OPT__(, ) __VA_ARGS__);
142 #define log_w(message, ...) \
143 if (get_log_level() > 1) \
144 log_format(__stderrp, YLW("wrn"), YLW(message) __VA_OPT__(, ) __VA_ARGS__);
148 #define log_e(message, ...) \
149 if (get_log_level() > 0) \
150 log_format(__stderrp, RED("err"), RED(message) __VA_OPT__(, ) __VA_ARGS__);
154 #define _fun_print_tmpl "%s "
155 #define _fun_print_arg , __func__
157 #define _fun_print_tmpl ""
158 #define _fun_print_arg
161 #define _file_print_tmpl "(%s:%d) "
162 #define _file_print_arg , __FILENAME__, __LINE__
164 #define _file_print_tmpl ""
165 #define _file_print_arg
194 #define log_format(file, tag, message, ...) \
195 fprintf(file, "[%s] " _fun_print_tmpl _file_print_tmpl message "\n", \
196 tag _fun_print_arg _file_print_arg __VA_OPT__(, ) __VA_ARGS__);