1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef LOGGER_H
- #define LOGGER_H
- #include <iostream>
- namespace Logger {
- enum Level { L_NONE, L_ERROR, L_WARNING, L_INFO, L_DEBUG };
- extern Level level;
- }
- #if LOG_LEVEL >= 1
- #define LOG_ERROR(text) \
- if(Logger::level >= Logger::Level::L_ERROR) { \
- std::cout << "\33[1;31m[ERROR] " << (text) << "\33[39;49m\n"; \
- }
- #else
- #define LOG_ERROR(text)
- #endif
- #if LOG_LEVEL >= 2
- #define LOG_WARNING(text) \
- if(Logger::level >= Logger::Level::L_WARNING) { \
- std::cout << "\33[1;33m[WARNING] " << (text) << "\33[39;49m\n"; \
- }
- #else
- #define LOG_WARNING(text)
- #endif
- #if LOG_LEVEL >= 3
- #define LOG_INFO(text) \
- if(Logger::level >= Logger::Level::L_INFO) { \
- std::cout << "\33[1;37m[INFO] " << (text) << "\33[39;49m\n"; \
- }
- #else
- #define LOG_INFO(text)
- #endif
- #if LOG_LEVEL >= 4
- #define LOG_DEBUG(text) \
- if(Logger::level >= Logger::Level::L_DEBUG) { \
- std::cout << "\33[1;32m[DEBUG] " << (text) << "\33[39;49m\n"; \
- }
- #else
- #define LOG_DEBUG(text)
- #endif
- #endif
|