#ifndef INC_PRINT_H #define INC_PRINT_H #include #include #include "config.h" #include "color.h" #if DEBUG == 1 #define pr(...) do { printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__); } while (0) #else #define pr(...) #endif #if ENABLE_STDOUT == 1 #define pr_stdout(...) do { printf(__VA_ARGS__); } while (0) #define write_stdout(data, size) do { write(1, (data), (size)); } while (0) #else #define pr_stdout(...) #define write_stdout(data, size) #endif #if LOG_LEVEL >= 0 #if ENABLE_FILE_LINE_IN_OTHER_PR == 1 #define pr_generic(color, prefix, ...) do { \ printf(color "[%s:%d] " prefix, __FILE__, __LINE__); \ printf(__VA_ARGS__); \ printf(COLOR_RESET); \ } while (0) #else #define pr_generic(color, prefix, ...) do { \ printf(color prefix); \ printf(__VA_ARGS__); \ printf(COLOR_RESET); \ } while (0) #endif #else #define pr_generic(color, prefix, ...) #endif #if LOG_LEVEL >= 2 #define pr_err(...) pr_generic(COLOR_RED, "Error: ", __VA_ARGS__) #else #define pr_err(...) #endif #if LOG_LEVEL >= 3 #define pr_warn(...) pr_generic(COLOR_YELLOW, "Warning: ", __VA_ARGS__) #else #define pr_warn(...) #endif #if LOG_LEVEL >= 4 #define pr_info(...) pr_generic(COLOR_RESET, "Info: ", __VA_ARGS__) #else #define pr_info(...) #endif #endif