78 lines
1.5 KiB
C
78 lines
1.5 KiB
C
#ifndef INC_PRINT_H
|
|
#define INC_PRINT_H
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "config.h"
|
|
#include "color.h"
|
|
|
|
#if DEBUG == 1
|
|
#define pr(...) { printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__); }
|
|
#else
|
|
#define pr(...) {}
|
|
#endif
|
|
|
|
|
|
#if ENABLE_STDOUT == 1
|
|
#define pr_stdout(...) { printf(__VA_ARGS__); }
|
|
#define write_stdout(data, size) { write(1, (data), (size)); }
|
|
#else
|
|
#define pr_stdout(...) {}
|
|
#define write_stdout(data, size) {}
|
|
#endif
|
|
|
|
|
|
#if LOG_LEVEL >= 2
|
|
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
|
|
#define pr_err(...) { \
|
|
printf(COLOR_RED "[%s:%d] Error: ", __FILE__, __LINE__); \
|
|
printf(__VA_ARGS__); \
|
|
printf(COLOR_RESET); \
|
|
}
|
|
#else
|
|
#define pr_err(...) { \
|
|
printf(COLOR_RED "Error: "); \
|
|
printf(__VA_ARGS__); \
|
|
printf(COLOR_RESET);\
|
|
}
|
|
#endif
|
|
#else
|
|
#define pr_err(...) {}
|
|
#endif
|
|
|
|
#if LOG_LEVEL >= 3
|
|
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
|
|
#define pr_warn(...) { \
|
|
printf(COLOR_YELLOW "[%s:%d] Warning: ", __FILE__, __LINE__); \
|
|
printf(__VA_ARGS__); \
|
|
printf(COLOR_RESET); \
|
|
}
|
|
#else
|
|
#define pr_warn(...) { \
|
|
printf(COLOR_YELLOW "Warning: "); \
|
|
printf(__VA_ARGS__); \
|
|
printf(COLOR_RESET); \
|
|
}
|
|
#endif
|
|
#else
|
|
#define pr_warn(...) {}
|
|
#endif
|
|
|
|
#if LOG_LEVEL >= 4
|
|
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
|
|
#define pr_info(...) { \
|
|
printf("[%s:%d] Info: ", __FILE__, __LINE__); \
|
|
printf(__VA_ARGS__); \
|
|
}
|
|
#else
|
|
#define pr_info(...) { printf("Info: "); printf(__VA_ARGS__); }
|
|
#endif
|
|
#else
|
|
#define pr_info(...) {}
|
|
#endif
|
|
|
|
|
|
#endif
|