Author: mikej Date: Wed Jun 20 05:19:45 2007 New Revision: 5412 Modified: freeswitch/trunk/src/include/switch_log.h freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_core_io.c freeswitch/trunk/src/switch_core_session.c freeswitch/trunk/src/switch_log.c Log: add userdata param to switch_log_printf so we can pass uuid or other session or other identification information to the logger. Modified: freeswitch/trunk/src/include/switch_log.h ============================================================================== --- freeswitch/trunk/src/include/switch_log.h (original) +++ freeswitch/trunk/src/include/switch_log.h Wed Jun 20 05:19:45 2007 @@ -61,7 +61,7 @@ switch_time_t timestamp; /*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */ char *content; - + const char *userdata; /* To maintain abi, only add new elements to the end of this struct and do not delete any elements */ } switch_log_node_t; @@ -95,7 +95,7 @@ \note there are channel macros to supply the first 4 parameters */ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, - switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6, 7); + const char *userdata, switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6, 7); /*! \brief Shut down the logging engine Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Wed Jun 20 05:19:45 2007 @@ -511,9 +511,9 @@ SCSMF_DYNAMIC = (1 << 0) } switch_core_session_message_flag_t; -#define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__ -#define SWITCH_CHANNEL_LOG_CLEAN SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__ -#define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __SWITCH_FUNC__, __LINE__ +#define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, NULL +#define SWITCH_CHANNEL_LOG_CLEAN SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, NULL +#define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __SWITCH_FUNC__, __LINE__, NULL /*! \enum switch_channel_state_t Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Wed Jun 20 05:19:45 2007 @@ -711,7 +711,7 @@ if (state > CS_RING) { switch_channel_presence(channel, "unknown", (char *) state_names[state]); } - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]); switch_mutex_lock(channel->flag_mutex); channel->state = state; @@ -742,7 +742,7 @@ } } else { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_WARNING, + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]); /* we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee! */ @@ -1049,7 +1049,7 @@ switch_channel_state_t last_state = channel->state; channel->state = CS_HANGUP; channel->hangup_cause = hangup_cause; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause)); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", "%s", switch_channel_cause2str(channel->hangup_cause)); @@ -1072,7 +1072,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line) { if (!switch_channel_test_flag(channel, CF_RING_READY)) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name); switch_channel_set_flag(channel, CF_RING_READY); return SWITCH_STATUS_SUCCESS; } @@ -1092,7 +1092,7 @@ char *uuid; switch_core_session_t *other_session; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name); switch_channel_set_flag(channel, CF_EARLY_MEDIA); switch_channel_set_variable(channel, "endpoint_disposition", "EARLY MEDIA"); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PROGRESS) == SWITCH_STATUS_SUCCESS) { @@ -1168,7 +1168,7 @@ status = switch_core_session_receive_message(channel->session, &msg); if (status == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name); } return status; @@ -1213,7 +1213,7 @@ } switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER"); - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name); return SWITCH_STATUS_SUCCESS; } Modified: freeswitch/trunk/src/switch_core_io.c ============================================================================== --- freeswitch/trunk/src/switch_core_io.c (original) +++ freeswitch/trunk/src/switch_core_io.c Wed Jun 20 05:19:45 2007 @@ -746,7 +746,7 @@ switch_io_event_hook_kill_channel_t *ptr; switch_status_t status = SWITCH_STATUS_FALSE; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "Kill %s [%s]\n", switch_channel_get_name(session->channel), + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "Kill %s [%s]\n", switch_channel_get_name(session->channel), SIG_NAMES[sig]); if (session->endpoint_interface->io_routines->kill_channel) { Modified: freeswitch/trunk/src/switch_core_session.c ============================================================================== --- freeswitch/trunk/src/switch_core_session.c (original) +++ freeswitch/trunk/src/switch_core_session.c Wed Jun 20 05:19:45 2007 @@ -658,7 +658,7 @@ switch_memory_pool_t *pool; switch_event_t *event; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n", switch_channel_get_name((*session)->channel), switch_channel_state_name(switch_channel_get_state((*session)->channel))); Modified: freeswitch/trunk/src/switch_log.c ============================================================================== --- freeswitch/trunk/src/switch_log.c (original) +++ freeswitch/trunk/src/switch_log.c Wed Jun 20 05:19:45 2007 @@ -164,7 +164,7 @@ } SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, - switch_log_level_t level, const char *fmt, ...) + const char *userdata, switch_log_level_t level, const char *fmt, ...) { char *data = NULL; char *new_fmt = NULL;