Merge pull request #1672

cbdfa757 mlog: fix default logging being not verbose enough (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-02-04 17:27:19 +02:00
commit 602f31d187
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -77,6 +77,32 @@ static void mlog_set_common_prefix()
el::Loggers::setFilenameCommonPrefix(std::string(path, expected_ptr - path)); el::Loggers::setFilenameCommonPrefix(std::string(path, expected_ptr - path));
} }
static const char *get_default_categories(int level)
{
const char *categories = "";
switch (level)
{
case 0:
categories = "*:WARNING,net*:FATAL,global:INFO,verify:FATAL,stacktrace:INFO";
break;
case 1:
categories = "*:WARNING,global:INFO,stacktrace:INFO";
break;
case 2:
categories = "*:DEBUG";
break;
case 3:
categories = "*:TRACE";
break;
case 4:
categories = "*:TRACE";
break;
default:
break;
}
return categories;
}
void mlog_configure(const std::string &filename_base, bool console) void mlog_configure(const std::string &filename_base, bool console)
{ {
el::Configurations c; el::Configurations c;
@ -103,37 +129,11 @@ void mlog_configure(const std::string &filename_base, bool console)
const char *monero_log = getenv("MONERO_LOGS"); const char *monero_log = getenv("MONERO_LOGS");
if (!monero_log) if (!monero_log)
{ {
monero_log = "*:WARNING,net*:FATAL,global:INFO,verify:FATAL"; monero_log = get_default_categories(0);
} }
mlog_set_categories(monero_log); mlog_set_categories(monero_log);
} }
static const char *get_default_categories(int level)
{
const char *categories = "";
switch (level)
{
case 0:
categories = "*:FATAL,net*:FATAL,global:INFO,verify:FATAL,stacktrace:INFO";
break;
case 1:
categories = "*:WARNING,global:INFO,stacktrace:INFO";
break;
case 2:
categories = "*:DEBUG";
break;
case 3:
categories = "*:TRACE";
break;
case 4:
categories = "*:TRACE";
break;
default:
break;
}
return categories;
}
void mlog_set_categories(const char *categories) void mlog_set_categories(const char *categories)
{ {
el::Loggers::setCategories(categories); el::Loggers::setCategories(categories);