diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-09-22 17:54:58 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-09-22 18:08:14 +0100 |
commit | 792ba4f0fe88cb29e28d3bede2eacafce154bb64 (patch) | |
tree | 97bf6d4a5932dd431e29432c8aa7df561d712416 /contrib | |
parent | easylogging++: add categories getter (diff) | |
download | monero-792ba4f0fe88cb29e28d3bede2eacafce154bb64.tar.xz |
Log categories can now be added to and removed from
Also, set_log without parameters now prints the log categories
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/epee/include/misc_log_ex.h | 1 | ||||
-rw-r--r-- | contrib/epee/src/mlog.cpp | 41 |
2 files changed, 40 insertions, 2 deletions
diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index ec4bcbe2d..c79232357 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -125,6 +125,7 @@ std::string mlog_get_default_log_path(const char *default_filename); void mlog_configure(const std::string &filename_base, bool console); void mlog_set_categories(const char *categories); +std::string mlog_get_categories(); void mlog_set_log_level(int level); void mlog_set_log(const char *log); diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index f7efbe39d..4fd47a350 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -144,8 +144,45 @@ void mlog_configure(const std::string &filename_base, bool console) void mlog_set_categories(const char *categories) { - el::Loggers::setCategories(categories); - MLOG_LOG("New log categories: " << categories); + std::string new_categories; + if (*categories) + { + if (*categories == '+') + { + ++categories; + new_categories = mlog_get_categories(); + if (*categories) + { + if (!new_categories.empty()) + new_categories += ","; + new_categories += categories; + } + } + else if (*categories == '-') + { + ++categories; + new_categories = mlog_get_categories(); + std::vector<std::string> single_categories; + boost::split(single_categories, categories, boost::is_any_of(","), boost::token_compress_on); + for (const std::string &s: single_categories) + { + size_t pos = new_categories.find(s); + if (pos != std::string::npos) + new_categories = new_categories.erase(pos, s.size()); + } + } + else + { + new_categories = categories; + } + } + el::Loggers::setCategories(new_categories.c_str(), true); + MLOG_LOG("New log categories: " << el::Loggers::getCategories()); +} + +std::string mlog_get_categories() +{ + return el::Loggers::getCategories(); } // maps epee style log level to new logging system |