mirror of https://github.com/SChernykh/p2pool
Fixed setting max log level from command line
parent
7b197824fe
commit
8064865ba5
|
@ -107,7 +107,7 @@ static int do_status(p2pool *m_pool, const char * /* args */)
|
||||||
static int do_loglevel(p2pool * /* m_pool */, const char *args)
|
static int do_loglevel(p2pool * /* m_pool */, const char *args)
|
||||||
{
|
{
|
||||||
int level = atoi(args);
|
int level = atoi(args);
|
||||||
level = std::min(std::max(level, 0), 6);
|
level = std::min(std::max(level, 0), log::MAX_GLOBAL_LOG_LEVEL);
|
||||||
log::GLOBAL_LOG_LEVEL = level;
|
log::GLOBAL_LOG_LEVEL = level;
|
||||||
LOGINFO(0, "log level set to " << level);
|
LOGINFO(0, "log level set to " << level);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace p2pool {
|
||||||
namespace log {
|
namespace log {
|
||||||
|
|
||||||
extern int GLOBAL_LOG_LEVEL;
|
extern int GLOBAL_LOG_LEVEL;
|
||||||
|
constexpr int MAX_GLOBAL_LOG_LEVEL = 6;
|
||||||
|
|
||||||
enum class Severity {
|
enum class Severity {
|
||||||
Info,
|
Info,
|
||||||
|
|
|
@ -56,7 +56,7 @@ Params::Params(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strcmp(argv[i], "--loglevel") == 0) && (i + 1 < argc)) {
|
if ((strcmp(argv[i], "--loglevel") == 0) && (i + 1 < argc)) {
|
||||||
const int level = std::min(std::max(atoi(argv[++i]), 0), 5);
|
const int level = std::min(std::max(atoi(argv[++i]), 0), log::MAX_GLOBAL_LOG_LEVEL);
|
||||||
log::GLOBAL_LOG_LEVEL = level;
|
log::GLOBAL_LOG_LEVEL = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue