mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
tweak the session level logging to work on the console too
This commit is contained in:
parent
a0049b2296
commit
4dae523bca
@ -64,6 +64,7 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
char *userdata;
|
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_text_channel_t channel;
|
switch_text_channel_t channel;
|
||||||
|
switch_log_level_t slevel;
|
||||||
} switch_log_node_t;
|
} switch_log_node_t;
|
||||||
|
|
||||||
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
|
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
|
||||||
|
@ -1030,7 +1030,8 @@ typedef enum {
|
|||||||
SWITCH_LOG_CRIT = 2,
|
SWITCH_LOG_CRIT = 2,
|
||||||
SWITCH_LOG_ALERT = 1,
|
SWITCH_LOG_ALERT = 1,
|
||||||
SWITCH_LOG_CONSOLE = 0,
|
SWITCH_LOG_CONSOLE = 0,
|
||||||
SWITCH_LOG_INVALID = 64
|
SWITCH_LOG_INVALID = 64,
|
||||||
|
SWITCH_LOG_UNINIT = 1000,
|
||||||
} switch_log_level_t;
|
} switch_log_level_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -5472,12 +5472,20 @@ SWITCH_STANDARD_API(escape_function)
|
|||||||
#define UUID_LOGLEVEL_SYNTAX "<uuid> <level>"
|
#define UUID_LOGLEVEL_SYNTAX "<uuid> <level>"
|
||||||
SWITCH_STANDARD_API(uuid_loglevel)
|
SWITCH_STANDARD_API(uuid_loglevel)
|
||||||
{
|
{
|
||||||
switch_core_session_t *tsession = NULL;
|
switch_core_session_t *tsession = NULL, *bsession = NULL;
|
||||||
char *uuid = NULL, *text = NULL;
|
char *uuid = NULL, *text = NULL;
|
||||||
|
int b = 0;
|
||||||
|
|
||||||
if (!zstr(cmd) && (uuid = strdup(cmd))) {
|
if (!zstr(cmd) && (uuid = strdup(cmd))) {
|
||||||
if ((text = strchr(uuid, ' '))) {
|
if ((text = strchr(uuid, ' '))) {
|
||||||
*text++ = '\0';
|
*text++ = '\0';
|
||||||
|
|
||||||
|
if (!strncasecmp(text, "-b", 2)) {
|
||||||
|
b++;
|
||||||
|
if ((text = strchr(text, ' '))) {
|
||||||
|
*text++ = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5491,6 +5499,12 @@ SWITCH_STANDARD_API(uuid_loglevel)
|
|||||||
} else if ((tsession = switch_core_session_locate(uuid))) {
|
} else if ((tsession = switch_core_session_locate(uuid))) {
|
||||||
|
|
||||||
switch_core_session_set_loglevel(tsession, level);
|
switch_core_session_set_loglevel(tsession, level);
|
||||||
|
|
||||||
|
if (b && switch_core_session_get_partner(tsession, &bsession) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_core_session_set_loglevel(bsession, level);
|
||||||
|
switch_core_session_rwunlock(bsession);
|
||||||
|
}
|
||||||
|
|
||||||
stream->write_function(stream, "+OK\n");
|
stream->write_function(stream, "+OK\n");
|
||||||
switch_core_session_rwunlock(tsession);
|
switch_core_session_rwunlock(tsession);
|
||||||
} else {
|
} else {
|
||||||
|
@ -206,7 +206,7 @@ static switch_status_t switch_console_logger(const switch_log_node_t *node, swit
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (level > hard_log_level) {
|
if (level > hard_log_level && (node->slevel == SWITCH_LOG_UNINIT || level > node->slevel)) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,6 +531,11 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
|
|||||||
|
|
||||||
switch_assert(peer_channel);
|
switch_assert(peer_channel);
|
||||||
|
|
||||||
|
if (channel && switch_true(switch_channel_get_variable(channel, "session_copy_loglevel"))) {
|
||||||
|
(*new_session)->loglevel = session->loglevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((use_uuid = switch_event_get_header(var_event, "origination_uuid"))) {
|
if ((use_uuid = switch_event_get_header(var_event, "origination_uuid"))) {
|
||||||
use_uuid = switch_core_session_strdup(*new_session, use_uuid);
|
use_uuid = switch_core_session_strdup(*new_session, use_uuid);
|
||||||
if (switch_core_session_set_uuid(*new_session, use_uuid) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_set_uuid(*new_session, use_uuid) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -347,9 +347,11 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha
|
|||||||
const char *extra_fmt = "%s [%s] %s:%d%c%s";
|
const char *extra_fmt = "%s [%s] %s:%d%c%s";
|
||||||
#endif
|
#endif
|
||||||
switch_log_level_t limit_level = runtime.hard_log_level;
|
switch_log_level_t limit_level = runtime.hard_log_level;
|
||||||
|
switch_log_level_t special_level = SWITCH_LOG_UNINIT;
|
||||||
|
|
||||||
if (channel == SWITCH_CHANNEL_ID_SESSION && userdata) {
|
if (channel == SWITCH_CHANNEL_ID_SESSION && userdata) {
|
||||||
switch_core_session_t *session = (switch_core_session_t *) userdata;
|
switch_core_session_t *session = (switch_core_session_t *) userdata;
|
||||||
|
special_level = session->loglevel;
|
||||||
if (limit_level < session->loglevel) {
|
if (limit_level < session->loglevel) {
|
||||||
limit_level = session->loglevel;
|
limit_level = session->loglevel;
|
||||||
}
|
}
|
||||||
@ -478,11 +480,13 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha
|
|||||||
switch_set_string(node->func, funcp);
|
switch_set_string(node->func, funcp);
|
||||||
node->line = line;
|
node->line = line;
|
||||||
node->level = level;
|
node->level = level;
|
||||||
|
node->slevel = special_level;
|
||||||
node->content = content;
|
node->content = content;
|
||||||
node->timestamp = now;
|
node->timestamp = now;
|
||||||
node->channel = channel;
|
node->channel = channel;
|
||||||
if (channel == SWITCH_CHANNEL_ID_SESSION) {
|
if (channel == SWITCH_CHANNEL_ID_SESSION) {
|
||||||
node->userdata = userdata ? strdup(switch_core_session_get_uuid((switch_core_session_t *) userdata)) : NULL;
|
switch_core_session_t *session = (switch_core_session_t *) userdata;
|
||||||
|
node->userdata = userdata ? strdup(switch_core_session_get_uuid(session)) : NULL;
|
||||||
} else {
|
} else {
|
||||||
node->userdata = !zstr(userdata) ? strdup(userdata) : NULL;
|
node->userdata = !zstr(userdata) ? strdup(userdata) : NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user