1. Volodymyr Shamray
  2. plog

Commits

Volodymyr Shamray  committed a7a1fbb

performance increased for the case when writing messages of low severity

  • Participants
  • Parent commits d181392
  • Branches stable-bugfix

Comments (0)

Files changed (3)

File include/plog/log.h

View file
  • Ignore whitespace
 
 #define LOG(severity) \
     PLOG_RETRIEVE_OBJ(PLOG_THIS)\
-    if (plog::logger_holder::get_logger())\
+    if (plog::logger_holder::get_logger(severity))\
     *(plog::logger_holder::get_logger()) += plog::message(severity, CONTEXT_INFO(PLOG_THIS), plog::logger_holder::get_logger()->get_locale())
 
 #define LOG_IF(severity, condition) \
     PLOG_RETRIEVE_OBJ(PLOG_THIS)\
-    if (condition && plog::logger_holder::get_logger())\
+    if (condition && plog::logger_holder::get_logger(severity))\
     *(plog::logger_holder::get_logger()) += plog::message(severity, CONTEXT_INFO(PLOG_THIS), plog::logger_holder::get_logger()->get_locale())
 
 #define LOG_EVERY_N(severity, n) \

File include/plog/logger_holder.h

View file
  • Ignore whitespace
         void set_logger(logger* new_logger);
 
         logger* get_logger();
+        logger* get_logger(log_level severity);
 
         logger* release_logger();
     }

File src/plog/logger_holder.cpp

View file
  • Ignore whitespace
     return g_logger_instance.get();
 }
 
+plog::logger* plog::logger_holder::get_logger(log_level severity)
+{
+    if (g_logger_instance.get() && g_logger_instance->check_severity(severity))
+        return g_logger_instance.get();
+    else
+        return NULL;
+}
 plog::logger* plog::logger_holder::release_logger()
 {
     return g_logger_instance.release();