|
@@ -1,56 +1,47 @@
|
|
#ifndef LOGGER_H
|
|
#ifndef LOGGER_H
|
|
#define LOGGER_H
|
|
#define LOGGER_H
|
|
|
|
|
|
-#include "utils/StringBuffer.h"
|
|
|
|
|
|
+#include <iostream>
|
|
|
|
|
|
namespace Logger {
|
|
namespace Logger {
|
|
enum Level { NONE, ERROR, WARNING, INFO, DEBUG };
|
|
enum Level { NONE, ERROR, WARNING, INFO, DEBUG };
|
|
-
|
|
|
|
extern Level level;
|
|
extern Level level;
|
|
|
|
+}
|
|
|
|
|
|
- template<int N>
|
|
|
|
- void error(const StringBuffer<N>& s) {
|
|
|
|
#if LOG_LEVEL >= 1
|
|
#if LOG_LEVEL >= 1
|
|
- if(level >= ERROR) {
|
|
|
|
- std::cout << "\33[1;31m[ERROR] " << s << "\33[39;49m\n";
|
|
|
|
- }
|
|
|
|
|
|
+#define LOG_ERROR(text) \
|
|
|
|
+ if(Logger::level >= Logger::Level::ERROR) { \
|
|
|
|
+ std::cout << "\33[1;31m[ERROR] " << (text) << "\33[39;49m\n"; \
|
|
|
|
+ }
|
|
#else
|
|
#else
|
|
- (void)s;
|
|
|
|
|
|
+#define LOG_ERROR(text)
|
|
#endif
|
|
#endif
|
|
- }
|
|
|
|
|
|
|
|
- template<int N>
|
|
|
|
- void warn(const StringBuffer<N>& s) {
|
|
|
|
#if LOG_LEVEL >= 2
|
|
#if LOG_LEVEL >= 2
|
|
- if(level >= WARNING) {
|
|
|
|
- std::cout << "\33[1;33m[WARNING] " << s << "\33[39;49m\n";
|
|
|
|
- }
|
|
|
|
|
|
+#define LOG_WARNING(text) \
|
|
|
|
+ if(Logger::level >= Logger::Level::WARNING) { \
|
|
|
|
+ std::cout << "\33[1;33m[WARNING] " << (text) << "\33[39;49m\n"; \
|
|
|
|
+ }
|
|
#else
|
|
#else
|
|
- (void)s;
|
|
|
|
|
|
+#define LOG_WARNING(text)
|
|
#endif
|
|
#endif
|
|
- }
|
|
|
|
|
|
|
|
- template<int N>
|
|
|
|
- void info(const StringBuffer<N>& s) {
|
|
|
|
#if LOG_LEVEL >= 3
|
|
#if LOG_LEVEL >= 3
|
|
- if(level >= INFO) {
|
|
|
|
- std::cout << "\33[1;37m[INFO] " << s << "\33[39;49m\n";
|
|
|
|
- }
|
|
|
|
|
|
+#define LOG_INFO(text) \
|
|
|
|
+ if(Logger::level >= Logger::Level::INFO) { \
|
|
|
|
+ std::cout << "\33[1;37m[INFO] " << (text) << "\33[39;49m\n"; \
|
|
|
|
+ }
|
|
#else
|
|
#else
|
|
- (void)s;
|
|
|
|
|
|
+#define LOG_INFO(text)
|
|
#endif
|
|
#endif
|
|
- }
|
|
|
|
|
|
|
|
- template<int N>
|
|
|
|
- void debug(const StringBuffer<N>& s) {
|
|
|
|
#if LOG_LEVEL >= 4
|
|
#if LOG_LEVEL >= 4
|
|
- if(level >= DEBUG) {
|
|
|
|
- std::cout << "\33[1;32m[DEBUG] " << s << "\33[39;49m\n";
|
|
|
|
- }
|
|
|
|
|
|
+#define LOG_DEBUG(text) \
|
|
|
|
+ if(Logger::level >= Logger::Level::DEBUG) { \
|
|
|
|
+ std::cout << "\33[1;32m[DEBUG] " << (text) << "\33[39;49m\n"; \
|
|
|
|
+ }
|
|
#else
|
|
#else
|
|
- (void)s;
|
|
|
|
|
|
+#define LOG_DEBUG(text)
|
|
#endif
|
|
#endif
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
|
|
#endif
|
|
#endif
|