Fix regression, option --no-color not fully disabled colored output.

This commit is contained in:
XMRig 2017-06-19 10:58:28 +03:00
parent ed0972da85
commit 9bfa49b7d0
5 changed files with 23 additions and 24 deletions

View file

@ -48,10 +48,11 @@ App::App(int argc, char **argv) :
{ {
m_self = this; m_self = this;
Console::init(); m_options = Options::parse(argc, argv);
Console::init(m_options->colors(), m_options->background());
Cpu::init(); Cpu::init();
m_options = Options::parse(argc, argv);
m_network = new Network(m_options); m_network = new Network(m_options);
uv_signal_init(uv_default_loop(), &m_signal); uv_signal_init(uv_default_loop(), &m_signal);
@ -69,17 +70,17 @@ int App::exec()
return 0; return 0;
} }
if (!CryptoNight::init(m_options->algo(), m_options->algoVariant())) {
LOG_ERR("\"%s\" hash self-test failed.", m_options->algoName());
return 1;
}
uv_signal_start(&m_signal, App::onSignal, SIGHUP); uv_signal_start(&m_signal, App::onSignal, SIGHUP);
uv_signal_start(&m_signal, App::onSignal, SIGTERM); uv_signal_start(&m_signal, App::onSignal, SIGTERM);
uv_signal_start(&m_signal, App::onSignal, SIGINT); uv_signal_start(&m_signal, App::onSignal, SIGINT);
background(); background();
if (!CryptoNight::init(m_options->algo(), m_options->algoVariant())) {
LOG_ERR("\"%s\" hash self-test failed.", m_options->algoName());
return 1;
}
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash()); Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash());
Summary::print(); Summary::print();

View file

@ -40,10 +40,10 @@
Console *Console::m_self = nullptr; Console *Console::m_self = nullptr;
void Console::init() void Console::init(bool colors, bool background)
{ {
if (!m_self) { if (!m_self) {
m_self = new Console(); m_self = new Console(colors, background);
} }
} }
@ -97,7 +97,7 @@ void Console::message(Console::Level level, const char* fmt, ...)
stime.tm_hour, stime.tm_hour,
stime.tm_min, stime.tm_min,
stime.tm_sec, stime.tm_sec,
color, m_colors ? color : "",
fmt, fmt,
m_colors ? kCL_N : "" m_colors ? kCL_N : ""
); );
@ -121,10 +121,7 @@ void Console::text(const char* fmt, ...)
const int len = 64 + strlen(fmt) + 2; const int len = 64 + strlen(fmt) + 2;
char *buf = static_cast<char *>(alloca(len)); char *buf = static_cast<char *>(alloca(len));
sprintf(buf, "%s%s\n", sprintf(buf, "%s%s\n", fmt, m_colors ? kCL_N : "");
fmt,
m_colors ? kCL_N : ""
);
uv_mutex_lock(&m_mutex); uv_mutex_lock(&m_mutex);
@ -137,8 +134,9 @@ void Console::text(const char* fmt, ...)
} }
Console::Console() : Console::Console(bool colors, bool background) :
m_colors(true) m_background(background),
m_colors(colors)
{ {
uv_mutex_init(&m_mutex); uv_mutex_init(&m_mutex);
} }

View file

@ -51,16 +51,17 @@ public:
# endif # endif
static inline Console* i() { return m_self; } static inline Console* i() { return m_self; }
static void init(); static void init(bool colors, bool background);
void message(Level level, const char* fmt, ...); void message(Level level, const char* fmt, ...);
void text(const char* fmt, ...); void text(const char* fmt, ...);
private: private:
Console(); Console(bool colors, bool background);
static Console *m_self; bool m_background;
bool m_colors; bool m_colors;
static Console *m_self;
uv_mutex_t m_mutex; uv_mutex_t m_mutex;
}; };

View file

@ -34,7 +34,6 @@
#endif #endif
#include "Console.h"
#include "Cpu.h" #include "Cpu.h"
#include "donate.h" #include "donate.h"
#include "net/Url.h" #include "net/Url.h"
@ -173,7 +172,7 @@ Options::Options(int argc, char **argv) :
} }
if (!m_url) { if (!m_url) {
LOG_ERR("No pool URL supplied. Exiting.", argv[0]); fprintf(stderr, "No pool URL supplied. Exiting.");
return; return;
} }

View file

@ -27,14 +27,14 @@
#define APP_ID "xmrig" #define APP_ID "xmrig"
#define APP_NAME "XMRig" #define APP_NAME "XMRig"
#define APP_DESC "Monero (XMR) CPU miner" #define APP_DESC "Monero (XMR) CPU miner"
#define APP_VERSION "1.0.1" #define APP_VERSION "1.1.0-dev"
#define APP_DOMAIN "xmrig.com" #define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com" #define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com"
#define APP_VER_MAJOR 1 #define APP_VER_MAJOR 1
#define APP_VER_MINOR 0 #define APP_VER_MINOR 1
#define APP_VER_BUILD 1 #define APP_VER_BUILD 0
#define APP_VER_REV 0 #define APP_VER_REV 0
#ifdef _MSC_VER #ifdef _MSC_VER