Rename Console class to Log.
This commit is contained in:
parent
a791bc113e
commit
77d9beaf89
12 changed files with 57 additions and 60 deletions
|
@ -7,11 +7,11 @@ option(WITH_AEON "CryptoNight-Lite support" ON)
|
|||
set(HEADERS
|
||||
src/3rdparty/align.h
|
||||
src/App.h
|
||||
src/Console.h
|
||||
src/Cpu.h
|
||||
src/interfaces/IClientListener.h
|
||||
src/interfaces/IJobResultListener.h
|
||||
src/interfaces/IWorker.h
|
||||
src/log/Log.h
|
||||
src/Mem.h
|
||||
src/net/Client.h
|
||||
src/net/Job.h
|
||||
|
@ -45,7 +45,7 @@ set(HEADERS_CRYPTO
|
|||
|
||||
set(SOURCES
|
||||
src/App.cpp
|
||||
src/Console.cpp
|
||||
src/log/Log.cpp
|
||||
src/Mem.cpp
|
||||
src/net/Client.cpp
|
||||
src/net/Job.cpp
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
#include "App.h"
|
||||
#include "Console.h"
|
||||
#include "log/Log.h"
|
||||
#include "Cpu.h"
|
||||
#include "crypto/CryptoNight.h"
|
||||
#include "Mem.h"
|
||||
|
@ -51,7 +51,7 @@ App::App(int argc, char **argv) :
|
|||
Cpu::init();
|
||||
m_options = Options::parse(argc, argv);
|
||||
|
||||
Console::init(m_options->colors(), m_options->background());
|
||||
Log::init(m_options->colors(), m_options->background());
|
||||
|
||||
m_network = new Network(m_options);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "Console.h"
|
||||
#include "log/Log.h"
|
||||
#include "crypto/CryptoNight.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include <uv.h>
|
||||
|
||||
|
||||
#include "Console.h"
|
||||
#include "Cpu.h"
|
||||
#include "log/Log.h"
|
||||
#include "Mem.h"
|
||||
#include "net/Url.h"
|
||||
#include "Options.h"
|
||||
|
@ -50,21 +50,21 @@ static void print_versions()
|
|||
|
||||
|
||||
if (Options::i()->colors()) {
|
||||
Console::i()->text("\x1B[01;32m * \x1B[01;37mVERSIONS: \x1B[01;36mXMRig/%s\x1B[01;37m libuv/%s%s", APP_VERSION, uv_version_string(), buf);
|
||||
Log::i()->text("\x1B[01;32m * \x1B[01;37mVERSIONS: \x1B[01;36mXMRig/%s\x1B[01;37m libuv/%s%s", APP_VERSION, uv_version_string(), buf);
|
||||
} else {
|
||||
Console::i()->text(" * VERSIONS: XMRig/%s libuv/%s%s", APP_VERSION, uv_version_string(), buf);
|
||||
Log::i()->text(" * VERSIONS: XMRig/%s libuv/%s%s", APP_VERSION, uv_version_string(), buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void print_memory() {
|
||||
if (Options::i()->colors()) {
|
||||
Console::i()->text("\x1B[01;32m * \x1B[01;37mHUGE PAGES: %s, %s",
|
||||
Mem::isHugepagesAvailable() ? "\x1B[01;32mavailable" : "\x1B[01;31munavailable",
|
||||
Mem::isHugepagesEnabled() ? "\x1B[01;32menabled" : "\x1B[01;31mdisabled");
|
||||
Log::i()->text("\x1B[01;32m * \x1B[01;37mHUGE PAGES: %s, %s",
|
||||
Mem::isHugepagesAvailable() ? "\x1B[01;32mavailable" : "\x1B[01;31munavailable",
|
||||
Mem::isHugepagesEnabled() ? "\x1B[01;32menabled" : "\x1B[01;31mdisabled");
|
||||
}
|
||||
else {
|
||||
Console::i()->text(" * HUGE PAGES: %s, %s", Mem::isHugepagesAvailable() ? "available" : "unavailable", Mem::isHugepagesEnabled() ? "enabled" : "disabled");
|
||||
Log::i()->text(" * HUGE PAGES: %s, %s", Mem::isHugepagesAvailable() ? "available" : "unavailable", Mem::isHugepagesEnabled() ? "enabled" : "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,19 +72,19 @@ static void print_memory() {
|
|||
static void print_cpu()
|
||||
{
|
||||
if (Options::i()->colors()) {
|
||||
Console::i()->text("\x1B[01;32m * \x1B[01;37mCPU: %s (%d) %sx64 %sAES-NI",
|
||||
Cpu::brand(),
|
||||
Cpu::sockets(),
|
||||
Cpu::isX64() ? "\x1B[01;32m" : "\x1B[01;31m-",
|
||||
Cpu::hasAES() ? "\x1B[01;32m" : "\x1B[01;31m-");
|
||||
Log::i()->text("\x1B[01;32m * \x1B[01;37mCPU: %s (%d) %sx64 %sAES-NI",
|
||||
Cpu::brand(),
|
||||
Cpu::sockets(),
|
||||
Cpu::isX64() ? "\x1B[01;32m" : "\x1B[01;31m-",
|
||||
Cpu::hasAES() ? "\x1B[01;32m" : "\x1B[01;31m-");
|
||||
# ifndef XMRIG_NO_LIBCPUID
|
||||
Console::i()->text("\x1B[01;32m * \x1B[01;37mCPU L2/L3: %.1f MB/%.1f MB", Cpu::l2() / 1024.0, Cpu::l3() / 1024.0);
|
||||
Log::i()->text("\x1B[01;32m * \x1B[01;37mCPU L2/L3: %.1f MB/%.1f MB", Cpu::l2() / 1024.0, Cpu::l3() / 1024.0);
|
||||
# endif
|
||||
}
|
||||
else {
|
||||
Console::i()->text(" * CPU: %s (%d) %sx64 %sAES-NI", Cpu::brand(), Cpu::sockets(), Cpu::isX64() ? "" : "-", Cpu::hasAES() ? "" : "-");
|
||||
Log::i()->text(" * CPU: %s (%d) %sx64 %sAES-NI", Cpu::brand(), Cpu::sockets(), Cpu::isX64() ? "" : "-", Cpu::hasAES() ? "" : "-");
|
||||
# ifndef XMRIG_NO_LIBCPUID
|
||||
Console::i()->text(" * CPU L2/L3: %.1f MB/%.1f MB", Cpu::l2() / 1024.0, Cpu::l3() / 1024.0);
|
||||
Log::i()->text(" * CPU L2/L3: %.1f MB/%.1f MB", Cpu::l2() / 1024.0, Cpu::l3() / 1024.0);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
@ -100,28 +100,28 @@ static void print_threads()
|
|||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
Console::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, av=%d, donate=%d%%%s%s" : " * THREADS: %d, %s, av=%d, donate=%d%%%s%s",
|
||||
Options::i()->threads(),
|
||||
Options::i()->algoName(),
|
||||
Options::i()->algoVariant(),
|
||||
Options::i()->donateLevel(),
|
||||
Options::i()->nicehash() ? ", nicehash" : "", buf);
|
||||
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, av=%d, donate=%d%%%s%s" : " * THREADS: %d, %s, av=%d, donate=%d%%%s%s",
|
||||
Options::i()->threads(),
|
||||
Options::i()->algoName(),
|
||||
Options::i()->algoVariant(),
|
||||
Options::i()->donateLevel(),
|
||||
Options::i()->nicehash() ? ", nicehash" : "", buf);
|
||||
}
|
||||
|
||||
|
||||
static void print_pools()
|
||||
{
|
||||
Console::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mPOOL #1: \x1B[01;36m%s:%d" : " * POOL #1: %s:%d",
|
||||
Options::i()->url()->host(),
|
||||
Options::i()->url()->port());
|
||||
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mPOOL #1: \x1B[01;36m%s:%d" : " * POOL #1: %s:%d",
|
||||
Options::i()->url()->host(),
|
||||
Options::i()->url()->port());
|
||||
|
||||
if (!Options::i()->backupUrl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Console::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mPOOL #2: \x1B[01;36m%s:%d" : " * POOL #2: %s:%d",
|
||||
Options::i()->backupUrl()->host(),
|
||||
Options::i()->backupUrl()->port());
|
||||
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mPOOL #2: \x1B[01;36m%s:%d" : " * POOL #2: %s:%d",
|
||||
Options::i()->backupUrl()->host(),
|
||||
Options::i()->backupUrl()->port());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,21 +34,21 @@
|
|||
# include "3rdparty/winansi.h"
|
||||
#endif
|
||||
|
||||
#include "Console.h"
|
||||
#include "log/Log.h"
|
||||
|
||||
|
||||
Console *Console::m_self = nullptr;
|
||||
Log *Log::m_self = nullptr;
|
||||
|
||||
|
||||
void Console::init(bool colors, bool background)
|
||||
void Log::init(bool colors, bool background)
|
||||
{
|
||||
if (!m_self) {
|
||||
m_self = new Console(colors, background);
|
||||
m_self = new Log(colors, background);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Console::message(Console::Level level, const char* fmt, ...)
|
||||
void Log::message(Log::Level level, const char* fmt, ...)
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
tm stime;
|
||||
|
@ -113,7 +113,7 @@ void Console::message(Console::Level level, const char* fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
void Console::text(const char* fmt, ...)
|
||||
void Log::text(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
@ -134,7 +134,7 @@ void Console::text(const char* fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
Console::Console(bool colors, bool background) :
|
||||
Log::Log(bool colors, bool background) :
|
||||
m_background(background),
|
||||
m_colors(colors)
|
||||
{
|
|
@ -21,14 +21,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CONSOLE_H__
|
||||
#define __CONSOLE_H__
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
class Console
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
enum Level {
|
||||
|
@ -50,35 +50,35 @@ public:
|
|||
constexpr static const char* kCL_GRAY = "\x1B[90m";
|
||||
# endif
|
||||
|
||||
static inline Console* i() { return m_self; }
|
||||
static inline Log* i() { return m_self; }
|
||||
static void init(bool colors, bool background);
|
||||
|
||||
void message(Level level, const char* fmt, ...);
|
||||
void text(const char* fmt, ...);
|
||||
|
||||
private:
|
||||
Console(bool colors, bool background);
|
||||
Log(bool colors, bool background);
|
||||
|
||||
bool m_background;
|
||||
bool m_colors;
|
||||
static Console *m_self;
|
||||
static Log *m_self;
|
||||
uv_mutex_t m_mutex;
|
||||
};
|
||||
|
||||
|
||||
#define LOG_ERR(x, ...) Console::i()->message(Console::ERR, x, ##__VA_ARGS__)
|
||||
#define LOG_WARN(x, ...) Console::i()->message(Console::WARNING, x, ##__VA_ARGS__)
|
||||
#define LOG_NOTICE(x, ...) Console::i()->message(Console::NOTICE, x, ##__VA_ARGS__)
|
||||
#define LOG_INFO(x, ...) Console::i()->message(Console::INFO, x, ##__VA_ARGS__)
|
||||
#define LOG_ERR(x, ...) Log::i()->message(Log::ERR, x, ##__VA_ARGS__)
|
||||
#define LOG_WARN(x, ...) Log::i()->message(Log::WARNING, x, ##__VA_ARGS__)
|
||||
#define LOG_NOTICE(x, ...) Log::i()->message(Log::NOTICE, x, ##__VA_ARGS__)
|
||||
#define LOG_INFO(x, ...) Log::i()->message(Log::INFO, x, ##__VA_ARGS__)
|
||||
|
||||
#ifdef APP_DEBUG
|
||||
# define LOG_DEBUG(x, ...) Console::i()->message(Console::DEBUG, x, ##__VA_ARGS__)
|
||||
# define LOG_DEBUG_ERR(x, ...) Console::i()->message(Console::ERR, x, ##__VA_ARGS__)
|
||||
# define LOG_DEBUG_WARN(x, ...) Console::i()->message(Console::WARNING, x, ##__VA_ARGS__)
|
||||
# define LOG_DEBUG(x, ...) Log::i()->message(Log::DEBUG, x, ##__VA_ARGS__)
|
||||
# define LOG_DEBUG_ERR(x, ...) Log::i()->message(Log::ERR, x, ##__VA_ARGS__)
|
||||
# define LOG_DEBUG_WARN(x, ...) Log::i()->message(Log::WARNING, x, ##__VA_ARGS__)
|
||||
#else
|
||||
# define LOG_DEBUG(x, ...)
|
||||
# define LOG_DEBUG_ERR(x, ...)
|
||||
# define LOG_DEBUG_WARN(x, ...)
|
||||
#endif
|
||||
|
||||
#endif /* __CONSOLE_H__ */
|
||||
#endif /* __LOG_H__ */
|
|
@ -25,7 +25,7 @@
|
|||
#include <utility>
|
||||
|
||||
|
||||
#include "Console.h"
|
||||
#include "log/Log.h"
|
||||
#include "interfaces/IClientListener.h"
|
||||
#include "net/Client.h"
|
||||
#include "net/JobResult.h"
|
||||
|
|
|
@ -23,11 +23,10 @@
|
|||
|
||||
|
||||
#include <string.h>
|
||||
//#include <stdlib.h>
|
||||
|
||||
|
||||
#include "log/Log.h"
|
||||
#include "net/Job.h"
|
||||
#include "Console.h"
|
||||
|
||||
|
||||
static inline unsigned char hf_hex2bin(char c, bool &err)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <memory>
|
||||
|
||||
|
||||
#include "Console.h"
|
||||
#include "log/Log.h"
|
||||
#include "net/Client.h"
|
||||
#include "net/Network.h"
|
||||
#include "net/Url.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <cmath>
|
||||
#include <memory.h>
|
||||
|
||||
#include "Console.h"
|
||||
#include "log/Log.h"
|
||||
#include "Options.h"
|
||||
#include "workers/Hashrate.h"
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
#include "Console.h"
|
||||
|
||||
#include "Cpu.h"
|
||||
#include "Mem.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <cmath>
|
||||
|
||||
|
||||
#include "Console.h"
|
||||
#include "interfaces/IJobResultListener.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
|
|
Loading…
Reference in a new issue