Add option "-l, --log-file=FILE" and stub for option "-S, --syslog".

feature-httpd
XMRig 2017-06-23 03:12:46 +03:00
parent 1bfbc97c7d
commit c1b3802590
3 changed files with 31 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include "Cpu.h"
#include "crypto/CryptoNight.h"
#include "log/ConsoleLog.h"
#include "log/FileLog.h"
#include "log/Log.h"
#include "Mem.h"
#include "net/Network.h"
@ -58,6 +59,10 @@ App::App(int argc, char **argv) :
Log::add(new ConsoleLog(m_options->colors()));
}
if (m_options->logFile()) {
Log::add(new FileLog(m_options->logFile()));
}
m_network = new Network(m_options);
uv_signal_init(uv_default_loop(), &m_signal);

View File

@ -68,6 +68,12 @@ Options:\n\
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
-B, --background run the miner in the background\n\
-c, --config=FILE load a JSON-format configuration file\n\
-l, --log-file=FILE log all output to a file\n"
# ifdef HAVE_SYSLOG_H
"\
-S, --syslog use system log for output messages\n"
# endif
"\
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
--safe safe adjust threads and av settings for current CPU\n\
--nicehash enable nicehash support\n\
@ -77,7 +83,7 @@ Options:\n\
";
static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vb:";
static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vb:l:S";
static struct option const options[] = {
@ -90,6 +96,7 @@ static struct option const options[] = {
{ "donate-level", 1, nullptr, 1003 },
{ "help", 0, nullptr, 'h' },
{ "keepalive", 0, nullptr ,'k' },
{ "log-file", 1, nullptr, 'l' },
{ "max-cpu-usage", 1, nullptr, 1004 },
{ "nicehash", 0, nullptr, 1006 },
{ "no-color", 0, nullptr, 1002 },
@ -98,6 +105,7 @@ static struct option const options[] = {
{ "retries", 1, nullptr, 'r' },
{ "retry-pause", 1, nullptr, 'R' },
{ "safe", 0, nullptr, 1005 },
{ "syslog", 0, nullptr, 'S' },
{ "threads", 1, nullptr, 't' },
{ "url", 1, nullptr, 'o' },
{ "user", 1, nullptr, 'u' },
@ -139,6 +147,8 @@ Options::Options(int argc, char **argv) :
m_nicehash(false),
m_ready(false),
m_safe(false),
m_syslog(false),
m_logFile(nullptr),
m_pass(nullptr),
m_user(nullptr),
m_algo(0),
@ -263,6 +273,12 @@ bool Options::parseArg(int key, char *arg)
m_pass = strdup(arg);
break;
case 'l': /* --log-file */
free(m_logFile);
m_logFile = strdup(arg);
m_colors = false;
break;
case 'r': /* --retries */
v = strtol(arg, nullptr, 10);
if (v < 1 || v > 1000) {
@ -324,6 +340,11 @@ bool Options::parseArg(int key, char *arg)
m_colors = false;
break;
case 'S': /* --syslog */
m_syslog = true;
m_colors = false;
break;
case 'v': /* --av */
v = strtol(arg, nullptr, 10);
if (v < 0 || v > 1000) {

View File

@ -57,6 +57,8 @@ public:
inline bool isReady() const { return m_ready; }
inline bool keepAlive() const { return m_keepAlive; }
inline bool nicehash() const { return m_nicehash; }
inline bool syslog() const { return m_syslog; }
inline const char *logFile() const { return m_logFile; }
inline const char *pass() const { return m_pass; }
inline const char *user() const { return m_user; }
inline const Url *backupUrl() const { return m_backupUrl; }
@ -98,6 +100,8 @@ private:
bool m_nicehash;
bool m_ready;
bool m_safe;
bool m_syslog;
char *m_logFile;
char *m_pass;
char *m_user;
int m_algo;