Merge pull request #1948

62efe5f6 mlog: direct log category changes to file only (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-04-11 00:24:08 +02:00
commit de68b00596
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 9 additions and 4 deletions

View File

@ -33,8 +33,13 @@
INITIALIZE_EASYLOGGINGPP INITIALIZE_EASYLOGGINGPP
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "logging"
#define MLOG_BASE_FORMAT "%datetime{%Y-%M-%d %H:%m:%s.%g}\t%thread\t%level\t%logger\t%loc\t%msg" #define MLOG_BASE_FORMAT "%datetime{%Y-%M-%d %H:%m:%s.%g}\t%thread\t%level\t%logger\t%loc\t%msg"
#define MLOG_LOG(x) CINFO(el::base::Writer,el::base::DispatchAction::FileOnlyLog,MONERO_DEFAULT_LOG_CATEGORY) << x
using namespace epee; using namespace epee;
static std::string generate_log_filename(const char *base) static std::string generate_log_filename(const char *base)
@ -88,10 +93,10 @@ static const char *get_default_categories(int level)
switch (level) switch (level)
{ {
case 0: case 0:
categories = "*:WARNING,net:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO"; categories = "*:WARNING,net:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO,logging:INFO";
break; break;
case 1: case 1:
categories = "*:WARNING,global:INFO,stacktrace:INFO"; categories = "*:WARNING,global:INFO,stacktrace:INFO,logging:INFO";
break; break;
case 2: case 2:
categories = "*:DEBUG"; categories = "*:DEBUG";
@ -142,7 +147,7 @@ void mlog_configure(const std::string &filename_base, bool console)
void mlog_set_categories(const char *categories) void mlog_set_categories(const char *categories)
{ {
el::Loggers::setCategories(categories); el::Loggers::setCategories(categories);
MGINFO("New log categories: " << categories); MLOG_LOG("New log categories: " << categories);
} }
// maps epee style log level to new logging system // maps epee style log level to new logging system
@ -150,7 +155,7 @@ void mlog_set_log_level(int level)
{ {
const char *categories = get_default_categories(level); const char *categories = get_default_categories(level);
el::Loggers::setCategories(categories); el::Loggers::setCategories(categories);
MGINFO("New log categories: " << categories); MLOG_LOG("New log categories: " << categories);
} }
void mlog_set_log(const char *log) void mlog_set_log(const char *log)