diff --git a/docs/COMMAND_LINE.MD b/docs/COMMAND_LINE.MD index 3f2ba9c..1d4ff65 100644 --- a/docs/COMMAND_LINE.MD +++ b/docs/COMMAND_LINE.MD @@ -13,6 +13,7 @@ --light-mode Don't allocate RandomX dataset, saves 2GB of RAM --loglevel Verbosity of the log, integer number between 0 and 6 --data-dir Path to store general p2pool files (log, cache, peer data, etc.), default is current directory +--log-file Path to the log file, default is "p2pool.log" in p2pool's working directory --sidechain-config Name of the p2pool sidechain parameters file (only use it if you run your own sidechain) --data-api Path to the p2pool JSON data (use it in tandem with an external web-server). Not affected by --data-dir setting! --local-api Enable /local/ path in api path for Stratum Server and built-in miner statistics diff --git a/src/log.cpp b/src/log.cpp index e50fadf..aba690c 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -132,7 +132,7 @@ public: std::setlocale(LC_ALL, "en_001"); - m_logFilePath = DATA_DIR + log_file_name; + m_logFilePath = LOG_FILE_PATH.empty() ? (DATA_DIR + log_file_name) : LOG_FILE_PATH; m_buf.resize(BUF_SIZE); diff --git a/src/main.cpp b/src/main.cpp index 5c9aa54..a7f0caa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,6 +72,7 @@ void p2pool_usage() "--light-mode Don't allocate RandomX dataset, saves 2GB of RAM\n" "--loglevel Verbosity of the log, integer number between 0 and %d\n" "--data-dir Path to store general p2pool files (log, cache, peer data, etc.), default is current directory\n" + "--log-file Path to the log file, default is \"p2pool.log\" in p2pool's working directory\n" "--sidechain-config Name of the p2pool sidechain parameters file (only use it if you run your own sidechain)\n" "--data-api Path to the p2pool JSON data (use it in tandem with an external web-server). Not affected by --data-dir setting!\n" "--local-api Enable /local/ path in api path for Stratum Server and built-in miner statistics\n" @@ -248,11 +249,14 @@ int main(int argc, char* argv[]) } if ((strcmp(argv[i], "--data-dir") == 0) && (i + 1 < argc)) { - std::string path = argv[++i]; - p2pool::DATA_DIR = std::move(path); + p2pool::DATA_DIR = argv[++i]; p2pool::fixup_path(p2pool::DATA_DIR); } + if ((strcmp(argv[i], "--log-file") == 0) && (i + 1 < argc)) { + p2pool::LOG_FILE_PATH = argv[++i]; + } + if (!strcmp(argv[i], "--mini")) is_mini = true; if (!strcmp(argv[i], "--nano")) is_nano = true; } diff --git a/src/params.cpp b/src/params.cpp index 9d2f6ff..a4e3d9c 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -124,6 +124,12 @@ Params::Params(int argc, char* const argv[]) ok = true; } + if ((strcmp(argv[i], "--log-file") == 0) && (i + 1 < argc)) { + // Processed in main.cpp + ++i; + ok = true; + } + if ((strcmp(argv[i], "--sidechain-config") == 0) && (i + 1 < argc)) { m_sidechainConfig = argv[++i]; ok = true; diff --git a/src/util.cpp b/src/util.cpp index 5d22dfc..eb77c8a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -160,6 +160,7 @@ secure_zero_memory(volatile void* data, size_t size) const uint8_t ED25519_MASTER_PUBLIC_KEY[32] = {51,175,37,73,203,241,188,115,195,255,123,53,218,120,90,74,186,240,82,178,67,139,124,91,180,106,188,181,187,51,236,10}; std::string DATA_DIR; +std::string LOG_FILE_PATH; SoftwareID get_software_id(uint32_t value) { diff --git a/src/util.h b/src/util.h index 5720fbd..bf9c3fb 100644 --- a/src/util.h +++ b/src/util.h @@ -45,6 +45,7 @@ extern const char* VERSION; extern const uint8_t ED25519_MASTER_PUBLIC_KEY[32]; extern std::string DATA_DIR; +extern std::string LOG_FILE_PATH; enum class SoftwareID : uint32_t { P2Pool = 0,