diff options
-rw-r--r-- | cli-miner.cpp | 3 | ||||
-rw-r--r-- | config.txt | 8 | ||||
-rw-r--r-- | console.cpp | 19 | ||||
-rw-r--r-- | console.h | 2 | ||||
-rw-r--r-- | jconf.cpp | 13 | ||||
-rw-r--r-- | jconf.h | 2 |
6 files changed, 44 insertions, 3 deletions
diff --git a/cli-miner.cpp b/cli-miner.cpp index 469e5db..0382785 100644 --- a/cli-miner.cpp +++ b/cli-miner.cpp @@ -124,6 +124,9 @@ int main(int argc, char *argv[]) printer::inst()->print_str("'c' - connection\n"); printer::inst()->print_str("-------------------------------------------------------------------\n"); + if(strlen(jconf::inst()->GetOutputFile()) != 0) + printer::inst()->open_logfile(jconf::inst()->GetOutputFile()); + executor::inst()->ex_start(); int key; @@ -141,6 +141,14 @@ "h_print_time" : 60,
/*
+ * Output file
+ *
+ * output_file - This option will log all output to a file.
+ *
+ */
+"output_file" : "",
+
+/*
* Built-in web server
* I like checking my hashrate on my phone. Don't you?
* Keep in mind that you will need to set up port forwarding on your router if you want to access it from
diff --git a/console.cpp b/console.cpp index 00c31c9..6a2555b 100644 --- a/console.cpp +++ b/console.cpp @@ -155,6 +155,13 @@ printer* printer::oInst = nullptr; printer::printer() { verbose_level = LINF; + logfile = nullptr; +} + +bool printer::open_logfile(const char* file) +{ + logfile = fopen(file, "ab+"); + return logfile != nullptr; } void printer::print_msg(verbosity verbose, const char* fmt, ...) @@ -185,10 +192,22 @@ void printer::print_msg(verbosity verbose, const char* fmt, ...) std::unique_lock<std::mutex> lck(print_mutex); fputs(buf, stdout); + + if(logfile != nullptr) + { + fputs(buf, logfile); + fflush(logfile); + } } void printer::print_str(const char* str) { std::unique_lock<std::mutex> lck(print_mutex); fputs(str, stdout); + + if(logfile != nullptr) + { + fputs(str, logfile); + fflush(logfile); + } } @@ -31,6 +31,7 @@ public: inline void set_verbose_level(size_t level) { verbose_level = (verbosity)level; } void print_msg(verbosity verbose, const char* fmt, ...); void print_str(const char* str); + bool open_logfile(const char* file); private: printer(); @@ -38,4 +39,5 @@ private: std::mutex print_mutex; verbosity verbose_level; + FILE* logfile; }; @@ -45,9 +45,10 @@ using namespace rapidjson; /* * This enum needs to match index in oConfigValues, otherwise we will get a runtime error */ -enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, bNiceHashMode, bTlsMode, bTlsSecureAlgo, sTlsFingerprint, - sPoolAddr, sWalletAddr, sPoolPwd, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime, iHttpdPort, - bPreferIpv4 }; +enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, bNiceHashMode, + bTlsMode, bTlsSecureAlgo, sTlsFingerprint, sPoolAddr, sWalletAddr, sPoolPwd, + iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime, + sOutputFile, iHttpdPort, bPreferIpv4 }; struct configVal { configEnum iName; @@ -72,6 +73,7 @@ configVal oConfigValues[] = { { iGiveUpLimit, "giveup_limit", kNumberType }, { iVerboseLevel, "verbose_level", kNumberType }, { iAutohashTime, "h_print_time", kNumberType }, + { sOutputFile, "output_file", kStringType }, { iHttpdPort, "httpd_port", kNumberType }, { bPreferIpv4, "prefer_ipv4", kTrueType } }; @@ -242,6 +244,11 @@ bool jconf::NiceHashMode() return prv->configValues[bNiceHashMode]->GetBool(); } +const char* jconf::GetOutputFile() +{ + return prv->configValues[sOutputFile]->GetString(); +} + bool jconf::check_cpu_features() { constexpr int AESNI_BIT = 1 << 25; @@ -43,6 +43,8 @@ public: uint64_t GetVerboseLevel(); uint64_t GetAutohashTime(); + const char* GetOutputFile(); + uint64_t GetCallTimeout(); uint64_t GetNetRetry(); uint64_t GetGiveUpLimit(); |