[PATCH] Log level not being published.


Adrienne Ambrose <AAmbrose@...>
 

TESTING:-

 

This was requested for submission by Damian from the list of differences between openmama & the enterprise versions. 

forcevalog patch needed sent out, which is used to add a custom prefix to the start of the line being logged.

 

 

PATCH:- 0001-Used-to-add-a-custom-prefix-to-the-start-of-the-line

From 4bb74689f23c25bc14c43515d24e7342a56a6be1 Mon Sep 17 00:00:00 2001

From: A Ambrose <aambrose@...>

Date: Wed, 30 Jul 2014 11:47:20 +0100

Subject: [PATCH] Used to add a custom prefix to the start of the line being logged

log lines now indicate the log level. Log levels include

[Init/Warning/Verbose/Debug/Info/Error]

[OMAMA-277]

Signed-off-by: A Ambrose <aambrose@...>

 

---

mama/c_cpp/src/c/log.c      |   35 +++++++++++++++++++++++++++++++++++

mama/c_cpp/src/c/mama/log.h |    8 ++++++++

2 files changed, 43 insertions(+), 0 deletions(-)

 

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

index b8ed3dd..ab4ae91 100644

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

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

@@ -1059,6 +1059,41 @@ mama_forceLogVa(const char   *format,

     logFunction(currentLevel, format, args);

}

+void

+mama_forceLogVaWithPrefix (const char* prefix,

+                           const char* format,

+                           va_list     args)

+{

+    MRSW_RESULT al = mamaLog_acquireLock(1);

+    if(MRSW_S_OK == al)

+    {

+        char    ts[MAMALOG_TIME_BUFFER_LENGTH] = "";

+        FILE*   f;

+

+        if (loggingToFile)

+        {

+            mamaLog_logLimitReached ();

+            f = gMamaControlledLogFile;

+        }

+        else

+        {

+            f = (gMamaLogFile == NULL) ? stderr : gMamaLogFile;

+        }

+

+        /* Format the current time */

+        mamaLog_getTime(ts, MAMALOG_TIME_BUFFER_LENGTH);

+

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

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

+        fprintf (f, "%s: ", prefix);

+        vfprintf (f, format, args);

+        fprintf (f, "\n");

+        fflush (f);

+

+        /* Release the read lock. */

+        MRSWLock_release(g_lock, 1);

+    }

+}

 void

mama_forceLog (MamaLogLevel level, const char *format, ...)

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

index b988a6c..58fb0b5 100644

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

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

@@ -145,6 +145,14 @@ mama_logVa (MamaLogLevel level, const char *format, va_list args);

MAMAExpDLL

extern void

mama_forceLogVa(const char   *format, va_list  args);

+

+/** Used to add a custom prefix to the start of the line being loggedf */

+MAMAExpDLL

+extern void

+mama_forceLogVaWithPrefix (const char* level,

+                           const char* format,

+                           va_list     args);

+

MAMAExpDLL

extern void

mama_forceLog (MamaLogLevel level, const char *format, ...);

--

1.7.1

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.