make logger handle a bit more bad input.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3306 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
2a645dbc6c
commit
964aec990c
|
@ -169,7 +169,8 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file
|
|||
int ret = 0;
|
||||
va_list ap;
|
||||
FILE *handle;
|
||||
char *filep = switch_cut_path(file);
|
||||
char *filep = (file ? switch_cut_path(file): "");
|
||||
const char *funcp = (func ? func : "");
|
||||
char *content = NULL;
|
||||
switch_time_t now = switch_time_now();
|
||||
uint32_t len;
|
||||
|
@ -186,9 +187,9 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file
|
|||
switch_time_exp_lt(&tm, now);
|
||||
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
|
||||
|
||||
len = (uint32_t)(strlen(extra_fmt) + strlen(date) + strlen(filep) + 32 + strlen(func) + strlen(fmt));
|
||||
len = (uint32_t)(strlen(extra_fmt) + strlen(date) + strlen(filep) + 32 + strlen(funcp) + strlen(fmt));
|
||||
new_fmt = malloc(len+1);
|
||||
snprintf(new_fmt, len, extra_fmt, date, LEVELS[level], filep, line, func, 128, fmt);
|
||||
snprintf(new_fmt, len, extra_fmt, date, LEVELS[level], filep, line, funcp, 128, fmt);
|
||||
fmt = new_fmt;
|
||||
}
|
||||
|
||||
|
@ -216,7 +217,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file
|
|||
if (switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", funcp);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Level", "%d", (int)level);
|
||||
switch_event_fire(&event);
|
||||
|
@ -231,7 +232,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file
|
|||
if ((node = malloc(sizeof(*node)))) {
|
||||
node->data = data;
|
||||
node->file = strdup(filep);
|
||||
node->func = strdup(func);
|
||||
node->func = strdup(funcp);
|
||||
node->line = line;
|
||||
node->level = level;
|
||||
node->content = content;
|
||||
|
|
|
@ -167,13 +167,17 @@ SWITCH_DECLARE(char *) switch_cut_path(char *in)
|
|||
char delims[] = "/\\";
|
||||
char *i;
|
||||
|
||||
for (i = delims; *i; i++) {
|
||||
p = in;
|
||||
while ((p = strchr(p, *i)) != 0) {
|
||||
ret = ++p;
|
||||
if (in) {
|
||||
for (i = delims; *i; i++) {
|
||||
p = in;
|
||||
while ((p = strchr(p, *i)) != 0) {
|
||||
ret = ++p;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
|
||||
|
|
Loading…
Reference in New Issue