Add ConsoleLog class and ILogBackend interface.
This commit is contained in:
parent
91ed7e36cd
commit
052290d0e9
7 changed files with 232 additions and 91 deletions
|
@ -26,6 +26,10 @@
|
|||
|
||||
|
||||
#include <uv.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class ILogBackend;
|
||||
|
||||
|
||||
class Log
|
||||
|
@ -50,19 +54,19 @@ public:
|
|||
constexpr static const char* kCL_GRAY = "\x1B[90m";
|
||||
# endif
|
||||
|
||||
static inline Log* i() { return m_self; }
|
||||
static void init(bool colors, bool background);
|
||||
static inline Log* i() { return m_self; }
|
||||
static inline void add(ILogBackend *backend) { i()->m_backends.push_back(backend); }
|
||||
static inline void init() { if (!m_self) { m_self = new Log();} }
|
||||
|
||||
void message(Level level, const char* fmt, ...);
|
||||
void text(const char* fmt, ...);
|
||||
|
||||
private:
|
||||
Log(bool colors, bool background);
|
||||
inline Log() {}
|
||||
~Log();
|
||||
|
||||
bool m_background;
|
||||
bool m_colors;
|
||||
static Log *m_self;
|
||||
uv_mutex_t m_mutex;
|
||||
std::vector<ILogBackend*> m_backends;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue