myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 1e035ef322


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 1e035ef322a4158bc570092a5d0d513c09163a55
Date: Tue, 11 Aug 2009 21:38:35 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  1e035ef322a4158bc570092a5d0d513c09163a55 (commit)
      from  b0c0c7ce4c8aa1211a95408dd94b8c619516ef0c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 1e035ef322a4158bc570092a5d0d513c09163a55
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Aug 11 23:37:07 2009 +0200

    Extract a method from LogManager::log (void*, string, string, LoggingLevel, 
bool, const char*, ...).

diff --git a/myserver/include/log/log_manager.h 
b/myserver/include/log/log_manager.h
index 36a5820..e01064d 100644
--- a/myserver/include/log/log_manager.h
+++ b/myserver/include/log/log_manager.h
@@ -27,6 +27,8 @@
 #include <include/filter/filters_factory.h>
 #include <include/log/stream/log_stream.h>
 #include <include/log/stream/log_stream_factory.h>
+#include <cstdarg>
+
 
 using namespace std;
 
@@ -46,6 +48,8 @@ public:
            bool appendNL = false, LoggingLevel level = MYSERVER_LOG_MSG_INFO);
   int log (void* owner, string type, string location, LoggingLevel level,
            bool appendNL, const char *fmt, ...);
+  int log (void* owner, string type, string location, LoggingLevel level,
+           bool appendNL, const char *fmt, va_list args);
 
   int close (void* owner);
   int close (void* owner, string type);
diff --git a/myserver/src/log/log_manager.cpp b/myserver/src/log/log_manager.cpp
index 8efb396..ba22a7f 100644
--- a/myserver/src/log/log_manager.cpp
+++ b/myserver/src/log/log_manager.cpp
@@ -17,7 +17,6 @@
 
 #include <include/log/log_manager.h>
 #include <include/server/server.h>
-#include <cstdarg>
 
 /*!
  * The constructor.
@@ -560,6 +559,32 @@ LogManager::log (void* owner, string type, string 
location, string message,
 /*!
  * Write a message on a single LogStream specifying a formatting string.
  *
+ * \see LogManager#log (void*, string, string, LoggingLeve, bool, va_list)
+ * \return 0 on success, 1 on error.
+ */
+int
+LogManager::log (void* owner, string type, string location, LoggingLevel level,
+                 bool appendNL, const char *fmt, ...)
+{
+  int failure = 0;
+
+  if (level < this->level)
+    return 1;
+
+  va_list argptr;
+
+  va_start (argptr, fmt);
+
+  failure = log (owner, type, location, level, appendNL, fmt, argptr);
+
+  va_end (argptr);
+
+  return failure;
+}
+
+/*!
+ * Write a message on a single LogStream specifying a formatting string.
+ *
  * \param owner The object that owns the LogStream.
  * \param type The log category where we want to write.
  * \param location The target LogStream.
@@ -575,12 +600,13 @@ LogManager::log (void* owner, string type, string 
location, string message,
  * %S A string*
  * %% A '%'.
  * %i An integer.
+ *\param args Additional args used by fmt.
  *
  * \return 0 on success, 1 on error.
  */
 int
 LogManager::log (void* owner, string type, string location, LoggingLevel level,
-                 bool appendNL, const char *fmt, ...)
+                 bool appendNL, const char *fmt, va_list args)
 {
   int failure = 0;
 
@@ -590,9 +616,6 @@ LogManager::log (void* owner, string type, string location, 
LoggingLevel level,
   mutex->lock ();
 
   ostringstream oss;
-  va_list argptr;
-
-  va_start (argptr, fmt);
 
   try
     {
@@ -606,11 +629,11 @@ LogManager::log (void* owner, string type, string 
location, LoggingLevel level,
               switch (*fmt)
                 {
                 case 's':
-                  oss << static_cast<const char*> (va_arg (argptr, const 
char*));
+                  oss << static_cast<const char*> (va_arg (args, const char*));
                   break;
 
                 case 'S':
-                  oss << static_cast<string*> (va_arg (argptr, string*));
+                  oss << static_cast<string*> (va_arg (args, string*));
                   break;
 
                 case '%':
@@ -618,16 +641,14 @@ LogManager::log (void* owner, string type, string 
location, LoggingLevel level,
                   break;
 
                 case 'i':
-                  oss << static_cast<int> (va_arg (argptr, int));
+                  oss << static_cast<int> (va_arg (args, int));
                   break;
 
                 default:
                   mutex->unlock ();
                   return 1;
                 }
-
             }
-
           fmt++;
         }
 
@@ -647,12 +668,10 @@ LogManager::log (void* owner, string type, string 
location, LoggingLevel level,
       mutex->unlock ();
     }
 
-  va_end (argptr);
-
   mutex->unlock ();
   return failure;
-}
 
+}
 
 /*!
  * Close all the LogStream objects owned by `owner'.

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/log/log_manager.h |    4 +++
 myserver/src/log/log_manager.cpp   |   45 +++++++++++++++++++++++++----------
 2 files changed, 36 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]