12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #ifndef CORE_LOGGER_H
- #define CORE_LOGGER_H
- #include "core/Check.h"
- #define TERMINAL_BOLD "\33[1m"
- #define TERMINAL_BLACK "\33[30m"
- #define TERMINAL_RED "\33[31m"
- #define TERMINAL_GREEN "\33[32m"
- #define TERMINAL_YELLOW "\33[33m"
- #define TERMINAL_BLUE "\33[34m"
- #define TERMINAL_MAGENTA "\33[35m"
- #define TERMINAL_CYAN "\33[36m"
- #define TERMINAL_WHITE "\33[37m"
- #define TERMINAL_BRIGHT_BLACK "\33[90m"
- #define TERMINAL_BRIGHT_RED "\33[91m"
- #define TERMINAL_BRIGHT_GREEN "\33[92m"
- #define TERMINAL_BRIGHT_YELLOW "\33[93m"
- #define TERMINAL_BRIGHT_BLUE "\33[94m"
- #define TERMINAL_BRIGHT_MAGENTA "\33[95m"
- #define TERMINAL_BRIGHT_CYAN "\33[96m"
- #define TERMINAL_BRIGHT_WHITE "\33[97m"
- #define TERMINAL_RESET "\33[0m"
- typedef enum { LOG_NONE, LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG } LogLevel;
- extern LogLevel logLevel;
- const char* getShortFileName(const char* s);
- check_format(6, 7) void printLog(LogLevel l, const char* file, int line,
- const char* prefix, const char* tag,
- const char* format, ...);
- #if defined(LOG_LEVEL) && LOG_LEVEL >= 1
- #define LOG_ERROR(...) \
- printLog(LOG_ERROR, __FILE__, __LINE__, TERMINAL_BRIGHT_RED, "[ERROR] ", \
- __VA_ARGS__)
- #else
- #define LOG_ERROR(...)
- #endif
- #if defined(LOG_LEVEL) && LOG_LEVEL >= 2
- #define LOG_WARNING(...) \
- printLog(LOG_WARNING, __FILE__, __LINE__, TERMINAL_BRIGHT_YELLOW, \
- "[WARNING] ", __VA_ARGS__)
- #else
- #define LOG_WARNING(...)
- #endif
- #if defined(LOG_LEVEL) && LOG_LEVEL >= 3
- #define LOG_INFO(...) \
- printLog(LOG_INFO, __FILE__, __LINE__, TERMINAL_BOLD, "[INFO] ", \
- __VA_ARGS__)
- #else
- #define LOG_INFO(...)
- #endif
- #if defined(LOG_LEVEL) && LOG_LEVEL >= 4
- #define LOG_DEBUG(...) \
- printLog(LOG_DEBUG, __FILE__, __LINE__, \
- TERMINAL_BOLD TERMINAL_BRIGHT_BLACK, "[DEBUG] ", __VA_ARGS__)
- #else
- #define LOG_DEBUG(...)
- #endif
- #endif
|