aboutsummaryrefslogtreecommitdiff
path: root/external/easylogging++/easylogging++.cc
diff options
context:
space:
mode:
Diffstat (limited to 'external/easylogging++/easylogging++.cc')
-rw-r--r--external/easylogging++/easylogging++.cc35
1 files changed, 28 insertions, 7 deletions
diff --git a/external/easylogging++/easylogging++.cc b/external/easylogging++/easylogging++.cc
index bf877c018..caaf7944c 100644
--- a/external/easylogging++/easylogging++.cc
+++ b/external/easylogging++/easylogging++.cc
@@ -17,6 +17,7 @@
#define EASYLOGGING_CC
#include "easylogging++.h"
+#include <atomic>
#include <unistd.h>
#if defined(AUTO_INITIALIZE_EASYLOGGINGPP)
@@ -2035,7 +2036,7 @@ void RegisteredLoggers::unsafeFlushAll(void) {
// VRegistry
-VRegistry::VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags) : m_level(level), m_pFlags(pFlags), m_lowest_priority(INT_MAX) {
+VRegistry::VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags) : m_level(level), m_pFlags(pFlags) {
}
/// @brief Sets verbose level. Accepted range is 0-9
@@ -2131,18 +2132,30 @@ static int priority(Level level) {
return 7;
}
+namespace
+{
+ std::atomic<int> s_lowest_priority{INT_MAX};
+}
+
+void VRegistry::clearCategories(void) {
+ const base::threading::ScopedLock scopedLock(lock());
+ m_categories.clear();
+ m_cached_allowed_categories.clear();
+ s_lowest_priority = INT_MAX;
+}
+
void VRegistry::setCategories(const char* categories, bool clear) {
base::threading::ScopedLock scopedLock(lock());
auto insert = [&](std::stringstream& ss, Level level) {
m_categories.push_back(std::make_pair(ss.str(), level));
m_cached_allowed_categories.clear();
int pri = priority(level);
- if (pri > m_lowest_priority)
- m_lowest_priority = pri;
+ if (pri > s_lowest_priority)
+ s_lowest_priority = pri;
};
if (clear) {
- m_lowest_priority = 0;
+ s_lowest_priority = 0;
m_categories.clear();
m_cached_allowed_categories.clear();
m_categoriesString.clear();
@@ -2200,9 +2213,9 @@ std::string VRegistry::getCategories() {
}
bool VRegistry::allowed(Level level, const std::string &category) {
- const int pri = priority(level);
- if (pri > m_lowest_priority)
- return false;
+ return priority_allowed(priority(level), category);
+}
+bool VRegistry::priority_allowed(const int pri, const std::string &category) {
base::threading::ScopedLock scopedLock(lock());
const std::map<std::string, int>::const_iterator it = m_cached_allowed_categories.find(category);
if (it != m_cached_allowed_categories.end())
@@ -3335,6 +3348,14 @@ void Helpers::logCrashReason(int sig, bool stackTraceIfAvailable, Level level, c
// Loggers
+bool Loggers::allowed(Level level, const char* cat)
+{
+ const int pri = base::priority(level);
+ if (pri > base::s_lowest_priority)
+ return false;
+ return ELPP->vRegistry()->priority_allowed(pri, std::string{cat});
+}
+
Logger* Loggers::getLogger(const std::string& identity, bool registerIfNotAvailable) {
return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
}