[PATCH] Added listenerMsgCallbackImpl_logUnknowStatus


Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This method refactors repeated logging statements and make the source easier to
follow.

Signed-off-by: Micheal Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/listenermsgcallback.c | 46 +++++++++++++++++++++++--------
1 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/mama/c_cpp/src/c/listenermsgcallback.c b/mama/c_cpp/src/c/listenermsgcallback.c
index cbc8224..9e770a9 100644
--- a/mama/c_cpp/src/c/listenermsgcallback.c
+++ b/mama/c_cpp/src/c/listenermsgcallback.c
@@ -64,6 +64,17 @@ listenerMsgCallbackImpl_invokeErrorCallback(listenerMsgCallback callback,
subscription, const char *userSymbol);

/**
+ * This function will write a log message if an unknown message status is detected.
+ *
+ * @param[in] ctx The subscription context.
+ * @param[in] status The message status.
+ * @param[in] subscription The subscription.
+ */
+static void
+listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, int status,
+ mamaSubscription subscription);
+
+/**
* Main callback for MamaListener. This is the base strategy for
* handling messages.
*/
@@ -303,21 +314,15 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,
* MISC status. */
break;
}
- /* else drop through to default... */
+
+ /* Otherwise log the fact we have received an unknown message. */
+ listenerMsgCallbackImpl_logUnknownStatus(ctx, status, subscription);
+ break;
}
default:
{
- if ((gMamaLogLevel >= MAMA_LOG_LEVEL_FINE) ||
- (mamaSubscription_checkDebugLevel (subscription,
- MAMA_LOG_LEVEL_FINE)))
- {
- const char* userSymbol = NULL;
- mamaSubscription_getSymbol (subscription, &userSymbol);
- mama_log (MAMA_LOG_LEVEL_FINE,
- "%s%s%s%s Unexpected status: %s",
- userSymbolFormatted, ctxSymbolFormatted,
- mamaMsgStatus_stringForStatus( status ) );
- }
+ /* Log the fact we have received an unknown message. */
+ listenerMsgCallbackImpl_logUnknownStatus(ctx, status, subscription);
}
}
}
@@ -572,3 +577,20 @@ void listenerMsgCallbackImpl_invokeErrorCallback(listenerMsgCallback callback, S
userSymbol,
closure);
}
+
+void listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, int status,
+ mamaSubscription subscription)
+{
+ /* Write the log at fine level. */
+ if ((gMamaLogLevel >= MAMA_LOG_LEVEL_FINE) ||
+ (mamaSubscription_checkDebugLevel (subscription,
+ MAMA_LOG_LEVEL_FINE)))
+ {
+ const char* userSymbol = NULL;
+ mamaSubscription_getSymbol (subscription, &userSymbol);
+ mama_log (MAMA_LOG_LEVEL_FINE,
+ "%s%s%s%s Unexpected status: %s",
+ userSymbolFormatted, ctxSymbolFormatted,
+ mamaMsgStatus_stringForStatus( status ) );
+ }
+}
--
1.7.5.4

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.