Commits

Igor Baidiuk  committed a6ae785

Fixed merge troubles. Next time will just close troublesome branch and rename needed one into it

  • Participants
  • Parent commits cc0c499

Comments (0)

Files changed (3)

         /// @param[in] level  log message level
         /// @return           reference to current message builder
         Logger& Level         (LogLevel    level);
-        /// Sets message tag
-        /// @param[in] tag    message textual tag
-        /// @return           reference to current message builder
-        Logger& Tag           (const char* tag);
         /// @defgroup Message write primitives
         /// @{
         

File log_impl.cpp

     * Compares two timestamps for equality
     * @param[in] right right-side timestamp value
     */
-    bool Timestamp::operator == (const Timestamp& right) const
+    bool operator == (const Timestamp& left, const Timestamp& right)
     {
         return
-            year         == right.year   &&
-            month        == right.month  &&
-            day          == right.day    &&
-            hour         == right.hour   &&
-            minute       == right.minute &&
-            second       == right.second &&
-            millisecond  == right.millisecond;
+            left.year         == right.year   &&
+            left.month        == right.month  &&
+            left.day          == right.day    &&
+            left.hour         == right.hour   &&
+            left.minute       == right.minute &&
+            left.second       == right.second &&
+            left.millisecond  == right.millisecond;
     }
     /**
     * Compares two timestamps for inequality. Based on equality operator
     * @param[in] right right-side timestamp value
     */
-    bool Timestamp::operator != (const Timestamp& right) const
+    bool operator != (const Timestamp& left, const Timestamp& right)
     {
-        return !(*this == right);
+        return !(left == right);
     }
 
-    const Timestamp Timestamp::Empty =
+    static const Timestamp Empty =
     {
         /* year         = */ 0,
         /* month        = */ 0,
         /* millisecond  = */ 0
     };
 
-    Timestamp Timestamp::Now()
+    static Timestamp Now()
     {
         Timestamp stamp;
 
         
         Message(const char* file, int line, const char* function, LogLevel level)
         {
-            info.timestamp = Timestamp::Now();
-            info.file = file;
-            info.line = line;
-            info.function = function;
-            info.level = level;
+            info.timestamp  = Now();
+            info.file       = file;
+            info.line       = line;
+            info.function   = function;
+            info.level      = level;
+            info.thread_id  = thread::CurrentThread();
+            
             text.push_back("");
         }
         
                 }
             }
             
-            bool IsLevelAcceptable(LogLevel level)
+            bool IsAcceptable(LogLevel level)
             {
                 return maxLevel == LevelUndefined || level <= maxLevel;
             }
     /**********************************************************************************
     * Logger class implementation
     *********************************************************************************/
+    static const Logger::Message* MSG_IGNORE = (Logger::Message*)~0ll;
+    
+    bool MakeMessage(Logger::Message*& msg, const char* file, int line, const char* func, LogLevel level)
+    {
+        if (msg == MSG_IGNORE)
+            return false;
+        
+        if (msg)
+            return true;
+        
+        if (!theLogger.IsAcceptable(level))
+        {
+            msg = (Logger::Message*)MSG_IGNORE;
+            return false;
+        }
+        
+        msg = new Logger::Message(file, line, func, level);
+        return true;
+    }
+    
     Logger::Logger(const char* file_in, int line_in, const char* function_in)
         : file      (namepart(file_in))
         , line      (line_in < 0 ? 0 : line_in)
 
     Logger::~Logger()
     {
-        if (message)
-        {
-            message->info.thread_id  = thread::CurrentThread();
+        if (message && message != MSG_IGNORE)
             theLogger.PushMessage(MessagePtr(message));
-        }
     }
 
     Logger& Logger::Level(LogLevel level_in)
 
     Logger& Logger::Write(const char* format, ...)
     {
-        if (!message)
-            message = new Message(file, line, function, level);
+        if (!MakeMessage(message, file, line, function, level))
+            return *this;;
         
         va_list args;
         va_start(args, format);
     
     Logger& Logger::operator () ()
     {
-        if (!message)
-            message = new Message(file, line, function, level);
+        if (!MakeMessage(message, file, line, function, level))
+            return *this;;
         
         message->NewLine();
         return *this;
 
     Logger& Logger::operator () (const char* format, ...)
     {
-        if (!message)
-            message = new Message(file, line, function, level);
+        if (!MakeMessage(message, file, line, function, level))
+            return *this;;
         
         va_list args;
         va_start(args, format);
                 case 't':
                     switch (*(newpos + 1))
                     {
+#if 0
                     case 'a':
                         // $tag
                         DIRECT_APPEND("tag", 2, info.tag);
                         break;
+#endif
                     case 'e':
                         // $text
                         DIRECT_APPEND_ACT("text", 2, "%s", had_text_token = true);