Go to the documentation of this file.
43 #define ANSI_COLOR_RED "\x1b[31m"
44 #define ANSI_COLOR_GREEN "\x1b[32m"
45 #define ANSI_COLOR_YELLOW "\x1b[33m"
46 #define ANSI_COLOR_BLUE "\x1b[34m"
47 #define ANSI_COLOR_RESET "\x1b[0m"
48 #define ANSI_COLOR_PURPLE "\x1b[35m"
50 #define PICO_SUPPORT_NDEBUG
65 #define log_at_level(lvl_label, color, fd, fmt, ...)\
66 fprintf(fd, "" color "%lu:%s:%d:%s(): " lvl_label ": " fmt ANSI_COLOR_RESET "\n", \
67 pthread_self(), __FILE__, __LINE__, __func__, ##__VA_ARGS__)
72 #define log_debug(fmt, ...)\
73 log_at_level("DEBUG", ANSI_COLOR_RESET, LOG_FD, fmt, ##__VA_ARGS__)
76 #define log_debug(...)
78 #define debug(fmt, ...) log_debug(__VA_ARGS__)
84 #define log_info(fmt, ...)\
85 log_at_level("INFO", ANSI_COLOR_GREEN, LOG_FD, fmt, ##__VA_ARGS__)
88 #define log_info(fmt, ...)
95 #define log_error(fmt, ...)\
96 log_at_level("ERROR", ANSI_COLOR_RED, LOG_FD, fmt, ##__VA_ARGS__)
98 #define log_perror(fmt, ...)\
99 log_at_level("ERROR", ANSI_COLOR_RED, LOG_FD, fmt ": %s", ##__VA_ARGS__, strerror(errno))
101 #define log_error(fmt, ...)
102 #define log_perror(fmt, ...)
109 #define log_warn(fmt, ...)\
110 log_at_level("WARN", ANSI_COLOR_YELLOW, LOG_FD, fmt, ##__VA_ARGS__)
113 #define log_warn(fmt, ...)
118 #if defined(LOG_CRITICAL) && LOG_CRITICAL
120 #define log_critical(fmt, ...)\
121 log_at_level("CRITICAL", ANSI_COLOR_PURPLE, LOG_FD, fmt, ##__VA_ARGS__)
124 #define log_critical(fmt, ...)
131 #define LOG_CUSTOM_STRINGIFY(val) "" #val
132 #define LOG_CUSTOM_STRINGIFY2(val) LOG_CUSTOM_STRINGIFY(val)
136 #define log(level, fmt, ...)\
138 if ((LOG_ALL || strcmp( "" #level, LOG_CUSTOM_STRINGIFY(level))) \
139 && !strcmp( "NO_" #level, LOG_CUSTOM_STRINGIFY2(NO_##level))) { \
140 log_at_level(#level, ANSI_COLOR_BLUE, LOG_FD, fmt, ##__VA_ARGS__); \
147 #define log(level, fmt, ...)
152 #if defined(DATA_PROFILING_PRINT) && DATA_PROFILING_PRINT
153 #define log_profile(fmt, ...) \
154 log_at_level("DATA_PROFILE", ANSI_COLOR_RESET, LOG_FD, fmt, ##__VA_ARGS__)
156 #define log_profile(...)
161 #if defined(LOG_TCP_DBG) && LOG_TCP_DBG
162 #define tcp_dbg(fmt, ...) \
163 log_at_level("TCP_DEBUG", ANSI_COLOR_RESET, LOG_FD, fmt, ##__VA_ARGS__)