mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-03 17:29:24 +00:00
Added --no-color
command line option
`--no-color` disables colors in console output
This commit is contained in:
parent
6a002cda46
commit
1c0da4513f
4 changed files with 14 additions and 1 deletions
|
@ -28,6 +28,7 @@ namespace p2pool {
|
||||||
namespace log {
|
namespace log {
|
||||||
|
|
||||||
int GLOBAL_LOG_LEVEL = 3;
|
int GLOBAL_LOG_LEVEL = 3;
|
||||||
|
bool CONSOLE_COLORS = true;
|
||||||
|
|
||||||
#ifndef P2POOL_LOG_DISABLE
|
#ifndef P2POOL_LOG_DISABLE
|
||||||
|
|
||||||
|
@ -159,6 +160,10 @@ private:
|
||||||
p += 3;
|
p += 3;
|
||||||
size -= 3;
|
size -= 3;
|
||||||
|
|
||||||
|
if (!CONSOLE_COLORS) {
|
||||||
|
strip_colors(p, size);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD k;
|
DWORD k;
|
||||||
WriteConsole((severity == 1) ? hStdOut : hStdErr, p, size, &k, nullptr);
|
WriteConsole((severity == 1) ? hStdOut : hStdErr, p, size, &k, nullptr);
|
||||||
|
@ -176,7 +181,9 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_logFile.is_open()) {
|
if (m_logFile.is_open()) {
|
||||||
strip_colors(p, size);
|
if (CONSOLE_COLORS) {
|
||||||
|
strip_colors(p, size);
|
||||||
|
}
|
||||||
|
|
||||||
if (severity == 1) {
|
if (severity == 1) {
|
||||||
m_logFile.write("NOTICE ", 8);
|
m_logFile.write("NOTICE ", 8);
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace p2pool {
|
||||||
namespace log {
|
namespace log {
|
||||||
|
|
||||||
extern int GLOBAL_LOG_LEVEL;
|
extern int GLOBAL_LOG_LEVEL;
|
||||||
|
extern bool CONSOLE_COLORS;
|
||||||
constexpr int MAX_GLOBAL_LOG_LEVEL = 6;
|
constexpr int MAX_GLOBAL_LOG_LEVEL = 6;
|
||||||
|
|
||||||
enum class Severity {
|
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"
|
"--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"
|
"--stratum-api Enable /local/ path in api path for Stratum Server statistics\n"
|
||||||
"--no-cache Disable p2pool.cache\n"
|
"--no-cache Disable p2pool.cache\n"
|
||||||
|
"--no-color Disable colors in console output\n"
|
||||||
"--help Show this help message\n\n"
|
"--help Show this help message\n\n"
|
||||||
"Example command line:\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",
|
"%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) {
|
if (strcmp(argv[i], "--no-cache") == 0) {
|
||||||
m_blockCache = false;
|
m_blockCache = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "--no-color") == 0) {
|
||||||
|
log::CONSOLE_COLORS = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_stratumAddresses.empty()) {
|
if (m_stratumAddresses.empty()) {
|
||||||
|
|
Loading…
Reference in a new issue