char *userdata;
/* 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_log_level_t slevel;
} switch_log_node_t;
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
SWITCH_LOG_CRIT = 2,
SWITCH_LOG_ALERT = 1,
SWITCH_LOG_CONSOLE = 0,
- SWITCH_LOG_INVALID = 64
+ SWITCH_LOG_INVALID = 64,
+ SWITCH_LOG_UNINIT = 1000,
} switch_log_level_t;
#define UUID_LOGLEVEL_SYNTAX "<uuid> <level>"
SWITCH_STANDARD_API(uuid_loglevel)
{
- switch_core_session_t *tsession = NULL;
+ switch_core_session_t *tsession = NULL, *bsession = NULL;
char *uuid = NULL, *text = NULL;
+ int b = 0;
if (!zstr(cmd) && (uuid = strdup(cmd))) {
if ((text = strchr(uuid, ' '))) {
*text++ = '\0';
+
+ if (!strncasecmp(text, "-b", 2)) {
+ b++;
+ if ((text = strchr(text, ' '))) {
+ *text++ = '\0';
+ }
+ }
}
}
} else if ((tsession = switch_core_session_locate(uuid))) {
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");
switch_core_session_rwunlock(tsession);
} else {
}
#endif
- if (level > hard_log_level) {
+ if (level > hard_log_level && (node->slevel == SWITCH_LOG_UNINIT || level > node->slevel)) {
return SWITCH_STATUS_SUCCESS;
}
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"))) {
use_uuid = switch_core_session_strdup(*new_session, use_uuid);
if (switch_core_session_set_uuid(*new_session, use_uuid) == SWITCH_STATUS_SUCCESS) {
const char *extra_fmt = "%s [%s] %s:%d%c%s";
#endif
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) {
switch_core_session_t *session = (switch_core_session_t *) userdata;
+ special_level = session->loglevel;
if (limit_level < session->loglevel) {
limit_level = session->loglevel;
}
switch_set_string(node->func, funcp);
node->line = line;
node->level = level;
+ node->slevel = special_level;
node->content = content;
node->timestamp = now;
node->channel = channel;
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 {
node->userdata = !zstr(userdata) ? strdup(userdata) : NULL;
}