| 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 e(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 19 | static void w(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 20 | static void d(const char *message, ...) __attribute__((format (printf, 1, 2))); |
| 21 |
| 22 | static FileLog &getInstance(); |
| 23 |
| 24 | private: |
| 25 | FILE *logFile = nullptr; |
| 26 | pthread_mutex_t mutex; |
| 27 | }; |
| 28 |
| 29 | extern bool LOGS_ENABLED; |
| 30 |
| 31 | #define DEBUG_E FileLog::getInstance().e |
| 32 | #define DEBUG_W FileLog::getInstance().w |
| 33 | #define DEBUG_D FileLog::getInstance().d |
| 34 |
| 35 | #endif |
| 36 |