diff --git a/src/log.cpp b/src/log.cpp index c97abde..d1858b1 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 09a0b16..392ce82 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" @@ -290,6 +291,10 @@ int main(int argc, char* argv[]) 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], "--params-file") == 0) && (i + 1 < argc)) { params_file = argv[++i]; } diff --git a/src/params.cpp b/src/params.cpp index 622ebfb..9dad0f2 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -130,6 +130,11 @@ Params::Params(const std::vector>& args) ok = true; } + if ((arg[0] == "log-file") && has1(arg)) { + // Processed in main.cpp + ok = true; + } + if ((arg[0] == "sidechain-config") && has1(arg)) { m_sidechainConfig = arg[1]; ok = true; diff --git a/src/util.cpp b/src/util.cpp index ab66e24..846b6cd 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -161,6 +161,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 2402c00..5f31b5d 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,