Basic advanced config reader, only single hash supported.
This commit is contained in:
parent
c44b299750
commit
c81401ab2d
7 changed files with 62 additions and 11 deletions
|
@ -4,8 +4,8 @@
|
|||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -38,6 +38,8 @@ Log *Log::m_self = nullptr;
|
|||
|
||||
void Log::message(Log::Level level, const char* fmt, ...)
|
||||
{
|
||||
uv_mutex_lock(&m_mutex);
|
||||
|
||||
va_list args;
|
||||
va_list copy;
|
||||
va_start(args, fmt);
|
||||
|
@ -47,11 +49,15 @@ void Log::message(Log::Level level, const char* fmt, ...)
|
|||
backend->message(level, fmt, copy);
|
||||
va_end(copy);
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
|
||||
void Log::text(const char* fmt, ...)
|
||||
{
|
||||
uv_mutex_lock(&m_mutex);
|
||||
|
||||
va_list args;
|
||||
va_list copy;
|
||||
va_start(args, fmt);
|
||||
|
@ -63,6 +69,8 @@ void Log::text(const char* fmt, ...)
|
|||
}
|
||||
|
||||
va_end(args);
|
||||
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -25,6 +25,7 @@
|
|||
#define __LOG_H__
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <uv.h>
|
||||
#include <vector>
|
||||
|
||||
|
@ -54,20 +55,28 @@ public:
|
|||
constexpr static const char* kCL_GRAY = "\x1B[90m";
|
||||
# endif
|
||||
|
||||
static inline Log* i() { return m_self; }
|
||||
static inline Log* i() { assert(m_self != nullptr); 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();} }
|
||||
static inline void release() { delete m_self; }
|
||||
static inline void init() { if (!m_self) { new Log(); } }
|
||||
static inline void release() { assert(m_self != nullptr); delete m_self; }
|
||||
|
||||
void message(Level level, const char* fmt, ...);
|
||||
void text(const char* fmt, ...);
|
||||
|
||||
private:
|
||||
inline Log() {}
|
||||
inline Log() {
|
||||
assert(m_self == nullptr);
|
||||
|
||||
uv_mutex_init(&m_mutex);
|
||||
|
||||
m_self = this;
|
||||
}
|
||||
|
||||
~Log();
|
||||
|
||||
static Log *m_self;
|
||||
std::vector<ILogBackend*> m_backends;
|
||||
uv_mutex_t m_mutex;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue