Mercurial > hg > freeDiameter
changeset 898:c2ecce3fb928
Add a NONE option for fd_msg_log to disable the trace
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 03 Dec 2012 21:27:19 +0100 |
parents | d8d0772586ad |
children | 40d5e8002b12 |
files | include/freeDiameter/libfdproto.h libfdproto/msg_log.c |
diffstat | 2 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/include/freeDiameter/libfdproto.h Fri Nov 30 23:14:34 2012 +0100 +++ b/include/freeDiameter/libfdproto.h Mon Dec 03 21:27:19 2012 +0100 @@ -2246,7 +2246,8 @@ /* configure the msg_log facility */ enum fd_msg_log_method { - FD_MSG_LOGTO_DEBUGONLY = 0, /* Simply log the message with other debug information, at the INFO level. This is default */ + FD_MSG_LOGTO_NONE = 0, /* The message is not dumped. This is the default. */ + FD_MSG_LOGTO_DEBUGONLY, /* Simply log the message with other debug information, at the INFO level. */ FD_MSG_LOGTO_FILE, /* Messages are dumped in a single file, defined in arg */ FD_MSG_LOGTO_DIR /* Messages are dumped in different files within one directory defined in arg. */ };
--- a/libfdproto/msg_log.c Fri Nov 30 23:14:34 2012 +0100 +++ b/libfdproto/msg_log.c Mon Dec 03 21:27:19 2012 +0100 @@ -63,8 +63,8 @@ /* Check the parameters are valid */ TRACE_ENTRY("%d %d %p", cause, method, arg); CHECK_PARAMS( (cause >= 0) && (cause <= FD_MSG_LOG_MAX) ); - CHECK_PARAMS( (method >= FD_MSG_LOGTO_DEBUGONLY) && (method <= FD_MSG_LOGTO_DIR) ); - CHECK_PARAMS( (method == FD_MSG_LOGTO_DEBUGONLY) || (arg != NULL) ); + CHECK_PARAMS( (method >= FD_MSG_LOGTO_NONE) && (method <= FD_MSG_LOGTO_DIR) ); + CHECK_PARAMS( (method == FD_MSG_LOGTO_NONE) || (method == FD_MSG_LOGTO_DEBUGONLY) || (arg != NULL) ); /* Lock the configuration */ CHECK_POSIX( pthread_mutex_lock(&ml_conf.lock) ); @@ -81,8 +81,12 @@ (cause == FD_MSG_LOG_DROPPED) ? "DROPPED" : (cause == FD_MSG_LOG_RECEIVED) ? "RECEIVED" : (cause == FD_MSG_LOG_SENT) ? "SENT" : + (cause == FD_MSG_LOG_NODELIVER) ? "NODELIVER" : + (cause == FD_MSG_LOG_TIMING) ? "TIMING" : "???", - (method == FD_MSG_LOGTO_FILE) ? "file" : + (method == FD_MSG_LOGTO_NONE) ? "none" : + (method == FD_MSG_LOGTO_DEBUGONLY) ? "debug" : + (method == FD_MSG_LOGTO_FILE) ? "file" : (method == FD_MSG_LOGTO_DIR) ? "directory" : "???", arg); @@ -129,8 +133,9 @@ metharg = ml_conf.causes[cause].metharg; CHECK_POSIX_DO( pthread_mutex_unlock(&ml_conf.lock), ); - /* Do not log if the level is not at least INFO */ - if ((meth == FD_MSG_LOGTO_DEBUGONLY) && (fd_g_debug_lvl < INFO)) { + /* Return now when loging is not requested */ + if ((meth == FD_MSG_LOGTO_NONE) + || ((meth == FD_MSG_LOGTO_DEBUGONLY) && (fd_g_debug_lvl < INFO))) { return; } @@ -186,9 +191,6 @@ /* And finally close the stream if needed */ switch (meth) { - case FD_MSG_LOGTO_DEBUGONLY: - break; - case FD_MSG_LOGTO_FILE: TODO("close?"); break;