16#include <glib/gprintf.h>
25#define IMQUIC_ANSI_COLOR_RED "\x1b[31m"
26#define IMQUIC_ANSI_COLOR_GREEN "\x1b[32m"
27#define IMQUIC_ANSI_COLOR_YELLOW "\x1b[33m"
28#define IMQUIC_ANSI_COLOR_BLUE "\x1b[34m"
29#define IMQUIC_ANSI_COLOR_MAGENTA "\x1b[35m"
30#define IMQUIC_ANSI_COLOR_CYAN "\x1b[36m"
31#define IMQUIC_ANSI_COLOR_RESET "\x1b[0m"
38#define IMQUIC_LOG_NONE (0)
40#define IMQUIC_LOG_FATAL (1)
42#define IMQUIC_LOG_ERR (2)
44#define IMQUIC_LOG_WARN (3)
46#define IMQUIC_LOG_INFO (4)
48#define IMQUIC_LOG_VERB (5)
50#define IMQUIC_LOG_HUGE (6)
52#define IMQUIC_LOG_DBG (7)
54#define IMQUIC_LOG_MAX IMQUIC_LOG_DBG
56#pragma GCC diagnostic push
57#pragma GCC diagnostic ignored "-Wunused-variable"
59static const char *imquic_log_prefix[] = {
80#pragma GCC diagnostic pop
86#define IMQUIC_PRINT g_print
90#define IMQUIC_LOG(level, format, ...) \
92 if (level > IMQUIC_LOG_NONE && level <= IMQUIC_LOG_MAX && level <= imquic_log_level) { \
93 char imquic_log_ts[64] = ""; \
94 char imquic_log_src[128] = ""; \
95 if (imquic_log_timestamps) { \
96 struct tm imquictmresult; \
97 time_t imquicltime = time(NULL); \
98 localtime_r(&imquicltime, &imquictmresult); \
99 strftime(imquic_log_ts, sizeof(imquic_log_ts), \
100 "[%a %b %e %T %Y] ", &imquictmresult); \
102 if (level == IMQUIC_LOG_FATAL || level == IMQUIC_LOG_ERR || level == IMQUIC_LOG_DBG) { \
103 snprintf(imquic_log_src, sizeof(imquic_log_src), \
104 "[%s:%s:%d] ", __FILE__, __FUNCTION__, __LINE__); \
106 g_print("%s%s%s" format, \
108 imquic_log_prefix[level | ((int)imquic_log_colors << 3)], \
#define IMQUIC_ANSI_COLOR_RESET
Definition debug.h:31
#define IMQUIC_ANSI_COLOR_YELLOW
Definition debug.h:27
#define IMQUIC_ANSI_COLOR_MAGENTA
Definition debug.h:29
#define IMQUIC_ANSI_COLOR_RED
Definition debug.h:25
int imquic_log_level
Definition imquic.c:26
gboolean imquic_log_timestamps
Definition imquic.c:27
gboolean imquic_log_colors
Definition imquic.c:28