Added `--no-color` command line option

`--no-color` disables colors in console output
pull/71/head
SChernykh 3 years ago
parent 6a002cda46
commit 1c0da4513f

@ -28,6 +28,7 @@ namespace p2pool {
namespace log {
int GLOBAL_LOG_LEVEL = 3;
bool CONSOLE_COLORS = true;
#ifndef P2POOL_LOG_DISABLE
@ -159,6 +160,10 @@ private:
p += 3;
size -= 3;
if (!CONSOLE_COLORS) {
strip_colors(p, size);
}
#ifdef _WIN32
DWORD k;
WriteConsole((severity == 1) ? hStdOut : hStdErr, p, size, &k, nullptr);
@ -176,7 +181,9 @@ private:
}
if (m_logFile.is_open()) {
strip_colors(p, size);
if (CONSOLE_COLORS) {
strip_colors(p, size);
}
if (severity == 1) {
m_logFile.write("NOTICE ", 8);

@ -22,6 +22,7 @@ namespace p2pool {
namespace log {
extern int GLOBAL_LOG_LEVEL;
extern bool CONSOLE_COLORS;
constexpr int MAX_GLOBAL_LOG_LEVEL = 6;
enum class Severity {

@ -38,6 +38,7 @@ static void usage()
"--data-api Path to the p2pool JSON data (use it in tandem with an external web-server)\n"
"--stratum-api Enable /local/ path in api path for Stratum Server statistics\n"
"--no-cache Disable p2pool.cache\n"
"--no-color Disable colors in console output\n"
"--help Show this help message\n\n"
"Example command line:\n\n"
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",

@ -77,6 +77,10 @@ Params::Params(int argc, char* argv[])
if (strcmp(argv[i], "--no-cache") == 0) {
m_blockCache = false;
}
if (strcmp(argv[i], "--no-color") == 0) {
log::CONSOLE_COLORS = false;
}
}
if (m_stratumAddresses.empty()) {

Loading…
Cancel
Save