Root/
| 1 | |
| 2 | #ifndef DEBUG_H |
| 3 | #define DEBUG_H |
| 4 | |
| 5 | #include <cstdio> |
| 6 | |
| 7 | #define NODEBUG_L 0 |
| 8 | #define ERROR_L 1 |
| 9 | #define WARNING_L 2 |
| 10 | #define INFO_L 3 |
| 11 | #define DEBUG_L 4 |
| 12 | |
| 13 | #ifndef LOG_LEVEL |
| 14 | #define LOG_LEVEL INFO_L |
| 15 | #endif |
| 16 | |
| 17 | // ------------- |
| 18 | |
| 19 | #ifndef COLOR_DEBUG |
| 20 | #define COLOR_DEBUG "\e[0;34m" |
| 21 | #endif |
| 22 | #ifndef COLOR_WARNING |
| 23 | #define COLOR_WARNING "\e[01;33m" |
| 24 | #endif |
| 25 | #ifndef COLOR_ERROR |
| 26 | #define COLOR_ERROR "\e[01;31m" |
| 27 | #endif |
| 28 | |
| 29 | #define COLOR_END "\e[0m" |
| 30 | |
| 31 | #if (LOG_LEVEL >= DEBUG_L) |
| 32 | # ifdef COLOR_DEBUG |
| 33 | # define DEBUG(str, ...) \ |
| 34 | fprintf(stdout, COLOR_DEBUG "DEBUG: " str COLOR_END, ##__VA_ARGS__) |
| 35 | # else |
| 36 | # define DEBUG(...) \ |
| 37 | fprintf(stdout, "DEBUG: " __VA_ARGS__) |
| 38 | # endif |
| 39 | #else |
| 40 | #define DEBUG(...) |
| 41 | #endif |
| 42 | |
| 43 | #if (LOG_LEVEL >= INFO_L) |
| 44 | # ifdef COLOR_INFO |
| 45 | # define INFO(str, ...) \ |
| 46 | fprintf(stdout, COLOR_INFO str COLOR_END, ##__VA_ARGS__) |
| 47 | # else |
| 48 | # define INFO(...) \ |
| 49 | fprintf(stdout, __VA_ARGS__) |
| 50 | # endif |
| 51 | #else |
| 52 | #define INFO(...) |
| 53 | #endif |
| 54 | |
| 55 | #if (LOG_LEVEL >= WARNING_L) |
| 56 | # ifdef COLOR_WARNING |
| 57 | # define WARNING(str, ...) \ |
| 58 | fprintf(stderr, COLOR_WARNING "WARNING: " str COLOR_END, ##__VA_ARGS__) |
| 59 | # else |
| 60 | # define WARNING(...) \ |
| 61 | fprintf(stderr, "WARNING: " __VA_ARGS__) |
| 62 | # endif |
| 63 | #else |
| 64 | #define WARNING(...) |
| 65 | #endif |
| 66 | |
| 67 | #if (LOG_LEVEL >= ERROR_L) |
| 68 | # ifdef COLOR_ERROR |
| 69 | # define ERROR(str, ...) \ |
| 70 | fprintf(stderr, COLOR_ERROR "ERROR: " str COLOR_END, ##__VA_ARGS__) |
| 71 | # else |
| 72 | # define ERROR(...) \ |
| 73 | fprintf(stderr, "ERROR: " __VA_ARGS__) |
| 74 | # endif |
| 75 | #else |
| 76 | #define ERROR(...) |
| 77 | #endif |
| 78 | |
| 79 | #endif |
| 80 |
Branches:
install_locations
master
opkrun
packages
