]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweak the session level logging to work on the console too
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 11 Oct 2012 17:44:31 +0000 (12:44 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 11 Oct 2012 17:44:31 +0000 (12:44 -0500)
src/include/switch_log.h
src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/loggers/mod_console/mod_console.c
src/switch_core_session.c
src/switch_log.c

index a44aa29a0132ff2baf1e6f19e38f189d80cc2938..603fcc2e1f99fdd28d659d29401e2fb7e4fc3080 100644 (file)
@@ -64,6 +64,7 @@ SWITCH_BEGIN_EXTERN_C
        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);
index 7bdf230690d409015844a14be9b1be9632a7976d..f1c5f1b65a8c8eeb2937ffedc4a6c1e7c14af17a 100644 (file)
@@ -1030,7 +1030,8 @@ typedef enum {
        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;
 
 
index 7287d95acc134ffc6bb0ea2b2d07dbff452be26a..679f29baaad1a185a3bc8c8966fefdd0e4c7de4e 100644 (file)
@@ -5472,12 +5472,20 @@ SWITCH_STANDARD_API(escape_function)
 #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';
+                               }
+                       }
                }
        }
 
@@ -5491,6 +5499,12 @@ SWITCH_STANDARD_API(uuid_loglevel)
                } 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 {
index 451cca78c3402eb50f7d3cafd5ce502fda50858b..a55a6bdc6adcbf00e9c9a2ad9e0365fbd0424629 100644 (file)
@@ -206,7 +206,7 @@ static switch_status_t switch_console_logger(const switch_log_node_t *node, swit
        }
 #endif
 
-       if (level > hard_log_level) {
+       if (level > hard_log_level && (node->slevel == SWITCH_LOG_UNINIT || level > node->slevel)) {
                return SWITCH_STATUS_SUCCESS;
        }
 
index ab52bb89ddee622bcaef69d8e27b6c4558cffa9a..a65688753adca249536289269583cb2fb9c3b40e 100644 (file)
@@ -531,6 +531,11 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
 
                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) {
index 9799a3698f00664d1c05b5a8eb6f67755fd9aeeb..c8bdad39177c0827e2d7a5750582c6881e4aad6a 100644 (file)
@@ -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";
 #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;
                }
@@ -478,11 +480,13 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha
                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;
                }