aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-10-02 23:28:59 +0400
committerRiccardo Spagni <ric@spagni.net>2017-10-02 23:28:59 +0400
commit3bab2676ec05ebd1f3d031c4fcdf7512412ccf05 (patch)
tree95a484e2981461b10f4371d4b45573890804c04f /contrib/epee
parentMerge pull request #2506 (diff)
parentLog categories can now be added to and removed from (diff)
downloadmonero-3bab2676ec05ebd1f3d031c4fcdf7512412ccf05.tar.xz
Merge pull request #2512
792ba4f0 Log categories can now be added to and removed from (moneromooo-monero) 48f92eb6 easylogging++: add categories getter (moneromooo-monero) f35afe62 epee: factor log level/categories setting (moneromooo-monero)
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/misc_log_ex.h1
-rw-r--r--contrib/epee/src/mlog.cpp44
2 files changed, 41 insertions, 4 deletions
diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h
index d351b024d..982aaea06 100644
--- a/contrib/epee/include/misc_log_ex.h
+++ b/contrib/epee/include/misc_log_ex.h
@@ -126,6 +126,7 @@
std::string mlog_get_default_log_path(const char *default_filename);
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size = MAX_LOG_FILE_SIZE);
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 964ba41df..cfb2b7b15 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -144,16 +144,52 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s
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
void mlog_set_log_level(int level)
{
const char *categories = get_default_categories(level);
- el::Loggers::setCategories(categories);
- MLOG_LOG("New log categories: " << categories);
+ mlog_set_categories(categories);
}
void mlog_set_log(const char *log)