aboutsummaryrefslogtreecommitdiff
path: root/external/easylogging++
diff options
context:
space:
mode:
Diffstat (limited to 'external/easylogging++')
-rw-r--r--external/easylogging++/easylogging++.cc49
-rw-r--r--external/easylogging++/easylogging++.h13
2 files changed, 39 insertions, 23 deletions
diff --git a/external/easylogging++/easylogging++.cc b/external/easylogging++/easylogging++.cc
index d57f3f3a0..f5f7481f8 100644
--- a/external/easylogging++/easylogging++.cc
+++ b/external/easylogging++/easylogging++.cc
@@ -2130,24 +2130,23 @@ static int priority(Level level) {
return 7;
}
-bool VRegistry::allowed(Level level, const char* category) {
+bool VRegistry::allowed(Level level, const std::string &category) {
base::threading::ScopedLock scopedLock(lock());
- const std::string scategory = category;
- const std::map<std::string, int>::const_iterator it = m_cached_allowed_categories.find(scategory);
+ const std::map<std::string, int>::const_iterator it = m_cached_allowed_categories.find(category);
if (it != m_cached_allowed_categories.end())
return priority(level) <= it->second;
- if (m_categories.empty() || category == nullptr) {
+ if (m_categories.empty()) {
return false;
} else {
std::vector<std::pair<std::string, Level>>::const_reverse_iterator it = m_categories.rbegin();
for (; it != m_categories.rend(); ++it) {
- if (base::utils::Str::wildCardMatch(category, it->first.c_str())) {
+ if (base::utils::Str::wildCardMatch(category.c_str(), it->first.c_str())) {
const int p = priority(it->second);
- m_cached_allowed_categories.insert(std::make_pair(std::move(scategory), p));
+ m_cached_allowed_categories.insert(std::make_pair(category, p));
return priority(level) <= p;
}
}
- m_cached_allowed_categories.insert(std::make_pair(std::move(scategory), -1));
+ m_cached_allowed_categories.insert(std::make_pair(category, -1));
return false;
}
}
@@ -2191,17 +2190,13 @@ void VRegistry::setFromArgs(const base::utils::CommandLineArgs* commandLineArgs)
# define ELPP_DEFAULT_LOGGING_FLAGS 0x0
#endif // !defined(ELPP_DEFAULT_LOGGING_FLAGS)
// Storage
-el::base::type::StoragePointer getresetELPP(bool reset)
+el::base::type::StoragePointer &el::base::Storage::getELPP()
{
- static el::base::type::StoragePointer p(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder())));
- if (reset)
- p = NULL;
- return p;
-}
-el::base::type::StoragePointer el::base::Storage::getELPP()
-{
- return getresetELPP(false);
+ if (!el::base::elStorage)
+ el::base::elStorage = new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()));
+ return el::base::elStorage;
}
+static struct EnsureELPP { EnsureELPP() { el::base::Storage::getELPP(); } } ensureELPP;
#if ELPP_ASYNC_LOGGING
Storage::Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker) :
#else
@@ -2250,7 +2245,6 @@ Storage::Storage(const LogBuilderPtr& defaultLogBuilder) :
Storage::~Storage(void) {
ELPP_INTERNAL_INFO(4, "Destroying storage");
- getresetELPP(true);
#if ELPP_ASYNC_LOGGING
ELPP_INTERNAL_INFO(5, "Replacing log dispatch callback to synchronous");
uninstallLogDispatchCallback<base::AsyncLogDispatchCallback>(std::string("AsyncLogDispatchCallback"));
@@ -2699,6 +2693,12 @@ Writer& Writer::construct(int count, const char* loggerIds, ...) {
return *this;
}
+Writer& Writer::construct(const char *loggerId) {
+ initializeLogger(ELPP->registeredLoggers()->get(loggerId, ELPP->hasFlag(LoggingFlag::CreateLoggerAutomatically)));
+ m_messageBuilder.initialize(m_logger);
+ return *this;
+}
+
void Writer::initializeLogger(const std::string& loggerId, bool lookup, bool needLock) {
if (lookup) {
m_logger = ELPP->registeredLoggers()->get(loggerId, ELPP->hasFlag(LoggingFlag::CreateLoggerAutomatically));
@@ -2720,13 +2720,26 @@ void Writer::initializeLogger(const std::string& loggerId, bool lookup, bool nee
}
if (ELPP->hasFlag(LoggingFlag::HierarchicalLogging)) {
m_proceed = m_level == Level::Verbose ? m_logger->enabled(m_level) :
- ELPP->vRegistry()->allowed(m_level, loggerId.c_str());
+ ELPP->vRegistry()->allowed(m_level, loggerId);
} else {
m_proceed = m_logger->enabled(m_level);
}
}
}
+void Writer::initializeLogger(Logger *logger, bool needLock) {
+ m_logger = logger;
+ if (m_logger == nullptr) {
+ m_proceed = false;
+ } else {
+ if (needLock) {
+ m_logger->acquireLock(); // This should not be unlocked by checking m_proceed because
+ // m_proceed can be changed by lines below
+ }
+ m_proceed = true;
+ }
+}
+
void Writer::processDispatch() {
#if ELPP_LOGGING_ENABLED
if (ELPP->hasFlag(LoggingFlag::MultiLoggerSupport)) {
diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h
index 046252a5b..d9a2dc3d1 100644
--- a/external/easylogging++/easylogging++.h
+++ b/external/easylogging++/easylogging++.h
@@ -552,7 +552,7 @@ typedef std::ostream ostream_t;
typedef unsigned int EnumType;
typedef unsigned short VerboseLevel;
typedef unsigned long int LineNumber;
-typedef std::shared_ptr<base::Storage> StoragePointer;
+typedef base::Storage *StoragePointer;
typedef std::shared_ptr<LogDispatchCallback> LogDispatchCallbackPtr;
typedef std::shared_ptr<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
typedef std::shared_ptr<LoggerRegistrationCallback> LoggerRegistrationCallbackPtr;
@@ -2463,7 +2463,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
void setModules(const char* modules);
- bool allowed(Level level, const char* category);
+ bool allowed(Level level, const std::string &category);
bool allowed(base::type::VerboseLevel vlevel, const char* file);
@@ -2734,7 +2734,7 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
return it->second;
}
- static el::base::type::StoragePointer getELPP();
+ static el::base::type::StoragePointer &getELPP();
private:
base::RegisteredHitCounters* m_registeredHitCounters;
@@ -3290,6 +3290,7 @@ class Writer : base::NoCopy {
Writer& construct(Logger* logger, bool needLock = true);
Writer& construct(int count, const char* loggerIds, ...);
+ Writer& construct(const char *loggerId);
protected:
LogMessage* m_msg;
Level m_level;
@@ -3305,6 +3306,7 @@ class Writer : base::NoCopy {
friend class el::Helpers;
void initializeLogger(const std::string& loggerId, bool lookup = true, bool needLock = true);
+ void initializeLogger(Logger *logger, bool needLock = true);
void processDispatch();
void triggerDispatch(void);
};
@@ -4613,9 +4615,10 @@ el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER); \
}
#if ELPP_ASYNC_LOGGING
-# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(NULL)
+# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\
+new el::base::AsyncDispatchWorker()))
#else
-# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(NULL)
+# define INITIALIZE_EASYLOGGINGPP ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder())))
#endif // ELPP_ASYNC_LOGGING
#define INITIALIZE_NULL_EASYLOGGINGPP \
namespace el {\