added verbosity levels option
This commit is contained in:
parent
d403dcf95c
commit
f6bcba49c3
10 changed files with 50 additions and 23 deletions
13
src/App.cpp
13
src/App.cpp
|
@ -69,18 +69,15 @@ App::App(int argc, char **argv) :
|
||||||
if (!m_options) {
|
if (!m_options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log::init(m_options->verbosity());
|
||||||
Log::init();
|
|
||||||
|
|
||||||
if (!m_options->background()) {
|
if (!m_options->background()) {
|
||||||
Log::add(new ConsoleLog(m_options->colors()));
|
Log::add(new ConsoleLog(m_options->colors()));
|
||||||
m_console = new Console(this);
|
m_console = new Console(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_options->logFile()) {
|
if (m_options->logFile()) {
|
||||||
Log::add(new FileLog(m_options->logFile()));
|
Log::add(new FileLog(m_options->logFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef HAVE_SYSLOG_H
|
# ifdef HAVE_SYSLOG_H
|
||||||
if (m_options->syslog()) {
|
if (m_options->syslog()) {
|
||||||
Log::add(new SysLog());
|
Log::add(new SysLog());
|
||||||
|
@ -126,7 +123,12 @@ int App::exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages());
|
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages());
|
||||||
Summary::print();
|
if(m_options->verbosity() == 2) {
|
||||||
|
Summary::printVerbose();
|
||||||
|
}
|
||||||
|
else if(m_options->verbosity() == 1) {
|
||||||
|
Summary::print();
|
||||||
|
}
|
||||||
|
|
||||||
# ifndef XMRIG_NO_API
|
# ifndef XMRIG_NO_API
|
||||||
Api::start();
|
Api::start();
|
||||||
|
@ -138,7 +140,6 @@ int App::exec()
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
Workers::start(m_options->affinity(), m_options->priority());
|
Workers::start(m_options->affinity(), m_options->priority());
|
||||||
|
|
||||||
m_network->connect();
|
m_network->connect();
|
||||||
|
|
||||||
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||||
|
|
|
@ -53,7 +53,6 @@ private:
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
static void onSignal(uv_signal_t *handle, int signum);
|
static void onSignal(uv_signal_t *handle, int signum);
|
||||||
|
|
||||||
static App *m_self;
|
static App *m_self;
|
||||||
|
|
||||||
Console *m_console;
|
Console *m_console;
|
||||||
|
|
|
@ -62,6 +62,7 @@ Options:\n\
|
||||||
-p, --pass=PASSWORD password for mining server\n\
|
-p, --pass=PASSWORD password for mining server\n\
|
||||||
-t, --threads=N number of miner threads\n\
|
-t, --threads=N number of miner threads\n\
|
||||||
-v, --av=N algorithm variation, 0 auto select\n\
|
-v, --av=N algorithm variation, 0 auto select\n\
|
||||||
|
-b, --verbosity=N verbosity level of logs (0-2), 2 auto select\n\
|
||||||
-k, --keepalive send keepalived for prevent timeout (need pool support)\n\
|
-k, --keepalive send keepalived for prevent timeout (need pool support)\n\
|
||||||
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
|
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
|
||||||
-R, --retry-pause=N time to pause between retries (default: 5)\n\
|
-R, --retry-pause=N time to pause between retries (default: 5)\n\
|
||||||
|
@ -91,12 +92,13 @@ Options:\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|
||||||
static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S";
|
static char const short_options[] = "a:b:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S";
|
||||||
|
|
||||||
|
|
||||||
static struct option const options[] = {
|
static struct option const options[] = {
|
||||||
{ "algo", 1, nullptr, 'a' },
|
{ "algo", 1, nullptr, 'a' },
|
||||||
{ "av", 1, nullptr, 'v' },
|
{ "av", 1, nullptr, 'v' },
|
||||||
|
{ "verbosity", 1, nullptr, 'b' },
|
||||||
{ "background", 0, nullptr, 'B' },
|
{ "background", 0, nullptr, 'B' },
|
||||||
{ "config", 1, nullptr, 'c' },
|
{ "config", 1, nullptr, 'c' },
|
||||||
{ "cpu-affinity", 1, nullptr, 1020 },
|
{ "cpu-affinity", 1, nullptr, 1020 },
|
||||||
|
@ -131,6 +133,7 @@ static struct option const options[] = {
|
||||||
static struct option const config_options[] = {
|
static struct option const config_options[] = {
|
||||||
{ "algo", 1, nullptr, 'a' },
|
{ "algo", 1, nullptr, 'a' },
|
||||||
{ "av", 1, nullptr, 'v' },
|
{ "av", 1, nullptr, 'v' },
|
||||||
|
{ "verbosity", 1, nullptr, 'b' },
|
||||||
{ "background", 0, nullptr, 'B' },
|
{ "background", 0, nullptr, 'B' },
|
||||||
{ "colors", 0, nullptr, 2000 },
|
{ "colors", 0, nullptr, 2000 },
|
||||||
{ "cpu-affinity", 1, nullptr, 1020 },
|
{ "cpu-affinity", 1, nullptr, 1020 },
|
||||||
|
@ -210,6 +213,7 @@ Options::Options(int argc, char **argv) :
|
||||||
m_userAgent(nullptr),
|
m_userAgent(nullptr),
|
||||||
m_algo(0),
|
m_algo(0),
|
||||||
m_algoVariant(0),
|
m_algoVariant(0),
|
||||||
|
m_verbosity(2),
|
||||||
m_apiPort(0),
|
m_apiPort(0),
|
||||||
m_donateLevel(kDonateLevel),
|
m_donateLevel(kDonateLevel),
|
||||||
m_maxCpuUsage(75),
|
m_maxCpuUsage(75),
|
||||||
|
@ -367,6 +371,7 @@ bool Options::parseArg(int key, const char *arg)
|
||||||
case 'r': /* --retries */
|
case 'r': /* --retries */
|
||||||
case 'R': /* --retry-pause */
|
case 'R': /* --retry-pause */
|
||||||
case 'v': /* --av */
|
case 'v': /* --av */
|
||||||
|
case 'b': /* --verbosity */
|
||||||
case 1003: /* --donate-level */
|
case 1003: /* --donate-level */
|
||||||
case 1004: /* --max-cpu-usage */
|
case 1004: /* --max-cpu-usage */
|
||||||
case 1007: /* --print-time */
|
case 1007: /* --print-time */
|
||||||
|
@ -414,7 +419,7 @@ bool Options::parseArg(int key, const char *arg)
|
||||||
free(m_userAgent);
|
free(m_userAgent);
|
||||||
m_userAgent = strdup(arg);
|
m_userAgent = strdup(arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
showUsage(1);
|
showUsage(1);
|
||||||
return false;
|
return false;
|
||||||
|
@ -462,6 +467,15 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
|
|
||||||
m_algoVariant = (int) arg;
|
m_algoVariant = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'b': /* --verbosity */
|
||||||
|
if(arg < 0 || arg > 2) {
|
||||||
|
showUsage(1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_verbosity = (int) arg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 1003: /* --donate-level */
|
case 1003: /* --donate-level */
|
||||||
if (arg < 1 || arg > 99) {
|
if (arg < 1 || arg > 99) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
inline const std::vector<Url*> &pools() const { return m_pools; }
|
inline const std::vector<Url*> &pools() const { return m_pools; }
|
||||||
inline int algo() const { return m_algo; }
|
inline int algo() const { return m_algo; }
|
||||||
inline int algoVariant() const { return m_algoVariant; }
|
inline int algoVariant() const { return m_algoVariant; }
|
||||||
|
inline int verbosity() const { return m_verbosity; }
|
||||||
inline int apiPort() const { return m_apiPort; }
|
inline int apiPort() const { return m_apiPort; }
|
||||||
inline int donateLevel() const { return m_donateLevel; }
|
inline int donateLevel() const { return m_donateLevel; }
|
||||||
inline int printTime() const { return m_printTime; }
|
inline int printTime() const { return m_printTime; }
|
||||||
|
@ -127,6 +128,7 @@ private:
|
||||||
int m_retries;
|
int m_retries;
|
||||||
int m_retryPause;
|
int m_retryPause;
|
||||||
int m_threads;
|
int m_threads;
|
||||||
|
int m_verbosity;
|
||||||
int64_t m_affinity;
|
int64_t m_affinity;
|
||||||
std::vector<Url*> m_pools;
|
std::vector<Url*> m_pools;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "Summary.h"
|
#include "Summary.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
static void print_versions()
|
static void print_versions()
|
||||||
{
|
{
|
||||||
char buf[16];
|
char buf[16];
|
||||||
|
@ -158,6 +157,19 @@ void Summary::print()
|
||||||
print_threads();
|
print_threads();
|
||||||
print_pools();
|
print_pools();
|
||||||
|
|
||||||
|
# ifndef XMRIG_NO_API
|
||||||
|
print_api();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Summary::printVerbose()
|
||||||
|
{
|
||||||
|
print_versions();
|
||||||
|
print_memory();
|
||||||
|
print_cpu();
|
||||||
|
print_threads();
|
||||||
|
print_pools();
|
||||||
|
|
||||||
# ifndef XMRIG_NO_API
|
# ifndef XMRIG_NO_API
|
||||||
print_api();
|
print_api();
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Summary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void print();
|
static void print();
|
||||||
|
static void printVerbose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ ConsoleLog::ConsoleLog(bool colors) :
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ConsoleLog::message(int level, const char* fmt, va_list args)
|
void ConsoleLog::message(int level, const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
if (!isWritable()) {
|
if (!isWritable()) {
|
||||||
|
@ -113,7 +112,7 @@ void ConsoleLog::message(int level, const char* fmt, va_list args)
|
||||||
m_colors ? color : "",
|
m_colors ? color : "",
|
||||||
fmt,
|
fmt,
|
||||||
m_colors ? Log::kCL_N : ""
|
m_colors ? Log::kCL_N : ""
|
||||||
);
|
);
|
||||||
|
|
||||||
print(args);
|
print(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
#include "interfaces/ILogBackend.h"
|
#include "interfaces/ILogBackend.h"
|
||||||
|
#include "App.h"
|
||||||
|
|
||||||
class ConsoleLog : public ILogBackend
|
class ConsoleLog : public ILogBackend
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,17 +35,17 @@
|
||||||
|
|
||||||
Log *Log::m_self = nullptr;
|
Log *Log::m_self = nullptr;
|
||||||
|
|
||||||
|
|
||||||
void Log::message(Log::Level level, const char* fmt, ...)
|
void Log::message(Log::Level level, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_list copy;
|
va_list copy;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
if(verbosity == 2) {
|
||||||
for (ILogBackend *backend : m_backends) {
|
for (ILogBackend *backend : m_backends) {
|
||||||
va_copy(copy, args);
|
va_copy(copy, args);
|
||||||
backend->message(level, fmt, copy);
|
backend->message(level, fmt, copy);
|
||||||
va_end(copy);
|
va_end(copy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ void Log::text(const char* fmt, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Log::~Log()
|
Log::~Log()
|
||||||
{
|
{
|
||||||
for (auto backend : m_backends) {
|
for (auto backend : m_backends) {
|
||||||
|
|
|
@ -56,18 +56,19 @@ public:
|
||||||
|
|
||||||
static inline Log* i() { return m_self; }
|
static inline Log* i() { return m_self; }
|
||||||
static inline void add(ILogBackend *backend) { i()->m_backends.push_back(backend); }
|
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 init(int verbosityL) { if (!m_self) {m_self = new Log(verbosityL);}}
|
||||||
static inline void release() { delete m_self; }
|
static inline void release() { delete m_self; }
|
||||||
|
|
||||||
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:
|
||||||
inline Log() {}
|
inline Log(int verbosityL): verbosity(verbosityL) {}
|
||||||
~Log();
|
~Log();
|
||||||
|
|
||||||
static Log *m_self;
|
static Log *m_self;
|
||||||
std::vector<ILogBackend*> m_backends;
|
std::vector<ILogBackend*> m_backends;
|
||||||
|
int verbosity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue