add userdata param to switch_log_printf so we can pass uuid or other session or other identification information to the logger.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5412 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-06-20 09:19:45 +00:00
parent 25f2fc817e
commit 5b27ad1332
6 changed files with 15 additions and 15 deletions

View File

@ -61,7 +61,7 @@ SWITCH_BEGIN_EXTERN_C
switch_time_t timestamp; switch_time_t timestamp;
/*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */ /*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */
char *content; char *content;
const char *userdata;
/* To maintain abi, only add new elements to the end of this struct and do not delete any elements */ /* To maintain abi, only add new elements to the end of this struct and do not delete any elements */
} switch_log_node_t; } switch_log_node_t;
@ -95,7 +95,7 @@ SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void);
\note there are channel macros to supply the first 4 parameters \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_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 \brief Shut down the logging engine

View File

@ -511,9 +511,9 @@ typedef enum {
SCSMF_DYNAMIC = (1 << 0) SCSMF_DYNAMIC = (1 << 0)
} switch_core_session_message_flag_t; } switch_core_session_message_flag_t;
#define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __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__ #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__ #define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
/*! /*!
\enum switch_channel_state_t \enum switch_channel_state_t

View File

@ -711,7 +711,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
if (state > CS_RING) { if (state > CS_RING) {
switch_channel_presence(channel, "unknown", (char *) state_names[state]); 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]); channel->name, state_names[last_state], state_names[state]);
switch_mutex_lock(channel->flag_mutex); switch_mutex_lock(channel->flag_mutex);
channel->state = state; channel->state = state;
@ -742,7 +742,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
} }
} else { } 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]); "%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! */ /* 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_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
switch_channel_state_t last_state = channel->state; switch_channel_state_t last_state = channel->state;
channel->state = CS_HANGUP; channel->state = CS_HANGUP;
channel->hangup_cause = hangup_cause; 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)); channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) { 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)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", "%s", switch_channel_cause2str(channel->hangup_cause));
@ -1072,7 +1072,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line) 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)) { 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); switch_channel_set_flag(channel, CF_RING_READY);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -1092,7 +1092,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
char *uuid; char *uuid;
switch_core_session_t *other_session; 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_flag(channel, CF_EARLY_MEDIA);
switch_channel_set_variable(channel, "endpoint_disposition", "EARLY MEDIA"); switch_channel_set_variable(channel, "endpoint_disposition", "EARLY MEDIA");
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PROGRESS) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PROGRESS) == SWITCH_STATUS_SUCCESS) {
@ -1168,7 +1168,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
status = switch_core_session_receive_message(channel->session, &msg); status = switch_core_session_receive_message(channel->session, &msg);
if (status == SWITCH_STATUS_SUCCESS) { 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; return status;
@ -1213,7 +1213,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
} }
switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER"); 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; return SWITCH_STATUS_SUCCESS;
} }

View File

@ -746,7 +746,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_
switch_io_event_hook_kill_channel_t *ptr; switch_io_event_hook_kill_channel_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE; 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]); SIG_NAMES[sig]);
if (session->endpoint_interface->io_routines->kill_channel) { if (session->endpoint_interface->io_routines->kill_channel) {

View File

@ -658,7 +658,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t *
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_event_t *event; 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_get_name((*session)->channel),
switch_channel_state_name(switch_channel_get_state((*session)->channel))); switch_channel_state_name(switch_channel_get_state((*session)->channel)));

View File

@ -164,7 +164,7 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t * thread, void *obj)
} }
SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, 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 *data = NULL;
char *new_fmt = NULL; char *new_fmt = NULL;