[PATCH] [mama] Added a log file rolling API


Ian Bell <IBell@...>
 

commit 5fa225447238332cc15512e2d065cdff4f15175c

Author: Ian Bell <IBell@...>

Date:   Thu May 17 21:44:26 2012 +0100

 

    [mama] Added a log file rolling API

    Signed-off-by: Ian Bell <IBell@...>

 

diff --git a/mama/c_cpp/src/c/log.c b/mama/c_cpp/src/c/log.c

index d6c99b7..a8ca6cc 100644

--- a/mama/c_cpp/src/c/log.c

+++ b/mama/c_cpp/src/c/log.c

@@ -1000,8 +1000,8 @@ mama_logDefault2 (MamaLogLevel level,

                fprintf (f, "(%x) : ", (unsigned int)wGetCurrentThreadId());

                               }

-                              fprintf (f, message);       

-        fprintf (f, "\n");

+                             fprintf (f, "%s", message);

+        fprintf (f, "%s", "\n");

         fflush (f);

     }

@@ -1222,3 +1222,16 @@ int mama_logDecrementVerbosity(MamaLogLevel* level)

     *level = MAMA_LOG_LEVEL_FINEST;

     return 1;

}

+

+mama_status mama_logForceRollLogFiles()

+{

+    mama_status ret = MAMA_STATUS_INVALID_ARG;

+    MRSW_RESULT          al = mamaLog_acquireLock(0);

+    if(MRSW_S_OK == al)

+             {

+        ret = mamaLog_rollLogFiles();

+                             /* Release the read lock. */

+                             MRSWLock_release(g_lock, 1);

+             }

+    return ret;

+}

diff --git a/mama/c_cpp/src/c/mama/log.h b/mama/c_cpp/src/c/mama/log.h

index 6c7915a..bd96fc7 100644

--- a/mama/c_cpp/src/c/mama/log.h

+++ b/mama/c_cpp/src/c/mama/log.h

@@ -282,6 +282,15 @@ MAMAExpDLL

extern int

mama_logDecrementVerbosity(MamaLogLevel* level);

+/**

+ * Force rolling the log file.

+ *

+ * @return The status of the operation.

+ */

+MAMAExpDLL

+extern mama_status

+mama_logForceRollLogFiles();

+

/**  Destroy memory held by the logging */

void

mama_logDestroy(void);

diff --git a/mama/c_cpp/src/cpp/MamaLogFile.cpp b/mama/c_cpp/src/cpp/MamaLogFile.cpp

index ca77c07..14955a5 100644

--- a/mama/c_cpp/src/cpp/MamaLogFile.cpp

+++ b/mama/c_cpp/src/cpp/MamaLogFile.cpp

@@ -93,4 +93,9 @@ namespace Wombat

         }

     }

+    void MamaLogFile::rollFiles()

+    {

+        mamaTry (mama_logForceRollLogFiles());

+    }

+

} // namespace Wombat

diff --git a/mama/c_cpp/src/cpp/mama/MamaLogFile.h b/mama/c_cpp/src/cpp/mama/MamaLogFile.h

index 4d4abd7..87b023b 100644

--- a/mama/c_cpp/src/cpp/mama/MamaLogFile.h

+++ b/mama/c_cpp/src/cpp/mama/MamaLogFile.h

@@ -88,6 +88,11 @@ namespace Wombat

          */

         static bool loggingToFile( void );

+        /**

+         * Perform a log file rolling.

+         */

+        static void rollFiles();

+

     private:

         /**

          * Utility class. No instances.



Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.