| 6 |
| * Copyright Nikolai Kudashov, 2015-2018. |
| 7 | */ |
| 8 |
| 9 | #ifndef FILELOG_H |
| 10 | #define FILELOG_H |
| 11 |
| 12 | #include "Defines.h" |
| 13 |
| 14 | class FileLog { |
| 15 | public: |
| 16 | FileLog(); |
| 17 | void init(std::string path); |
| 18 | static void fatal(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 19 | static void e(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 20 | static void w(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 21 | static void d(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 22 | static void ref(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 23 | static void delref(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 24 |
| 25 | static FileLog &getInstance(); |
| 26 |
| 27 | private: |
| 28 | FILE *logFile = nullptr; |
| 29 | pthread_mutex_t mutex; |
| 30 | }; |
| 31 |
| 32 | extern bool LOGS_ENABLED; |
| 33 |
| 34 | #define DEBUG_FATAL FileLog::getInstance().fatal |
| 35 | #define DEBUG_E FileLog::getInstance().e |
| 36 | #define DEBUG_W FileLog::getInstance().w |
| 37 | #define DEBUG_D FileLog::getInstance().d |
| 38 |
| 39 | #define DEBUG_REF FileLog::getInstance().ref |
| 40 | #define DEBUG_DELREF FileLog::getInstance().delref |
| 41 |
| 42 | #endif |
| 43 |