]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add sofia tracelevel <level> and tracelevel param in <settings>
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 9 Jun 2009 19:52:07 +0000 (19:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 9 Jun 2009 19:52:07 +0000 (19:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13735 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/switch_log.c
src/switch_utils.c

index 98767d3280e2dff15341fdb756337209d0f0524e..ca7154cfdef4da9cb66fda9b4cde9b998cc43a47 100644 (file)
@@ -2441,6 +2441,12 @@ SWITCH_STANDARD_API(sofia_function)
                func = cmd_status;
        } else if (!strcasecmp(argv[0], "xmlstatus")) {
                func = cmd_xml_status;
+       } else if (!strcasecmp(argv[0], "tracelevel")) {
+               if (argv[1]) {
+                       mod_sofia_globals.tracelevel = switch_log_str2level(argv[1]);
+               }
+               stream->write_function(stream, "+OK tracelevel is %s", switch_log_level2str(mod_sofia_globals.tracelevel));
+        goto done;
        } else if (!strcasecmp(argv[0], "loglevel")) {
                if (argc > 2 && argv[2] && switch_is_number(argv[2])) {
                        int level = atoi(argv[2]);
index 65a604913e1b5fa86e4c4dac889f8a7b82781cac..a27b26f5ee827f4ae259599503a299474ed9745d 100644 (file)
@@ -274,6 +274,7 @@ struct mod_sofia_globals {
        int debug_presence;
        int auto_restart;
        int auto_nat;
+       int tracelevel;
 };
 extern struct mod_sofia_globals mod_sofia_globals;
 
index fb781c756c14ed6c020e15c83a9e6df4a9b48ad3..08e2d5b221a2629c1720285906f30326fa761a60 100644 (file)
@@ -1003,9 +1003,9 @@ void launch_sofia_profile_thread(sofia_profile_t *profile)
 static void logger(void *logarg, char const *fmt, va_list ap)
 {
        if (fmt && ap) {
-               switch_log_vprintf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, fmt, ap);
+               switch_log_vprintf(SWITCH_CHANNEL_LOG_CLEAN, mod_sofia_globals.tracelevel, fmt, ap);
        } else if (fmt && !ap) {
-               switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "%s", fmt);
+               switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, mod_sofia_globals.tracelevel, "%s", fmt);
        }
 }
 
@@ -1521,6 +1521,8 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                        char *val = (char *) switch_xml_attr_soft(param, "value");
                                        if (!strcasecmp(var, "debug")) {
                                                profile->debug = atoi(val);
+                                       } else if (!strcasecmp(var, "tracelevel")) {
+                                               mod_sofia_globals.tracelevel = switch_log_str2level(val);
                                        } else if (!strcasecmp(var, "sip-trace")) {
                                                if (switch_true(val)) {
                                                        sofia_set_flag(profile, TFLAG_TPORT_LOG);
index ca686ddd11fe036ed408f94367f6203007913c87..f444f26c3ffe54fd47d4200e53328be2ac564d49 100644 (file)
@@ -120,6 +120,19 @@ SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str)
        int x = 0;
        switch_log_level_t level = SWITCH_LOG_INVALID;
 
+       if (switch_is_number(str)) {
+               x = atoi(str);
+
+               if (x > SWITCH_LOG_INVALID) {
+                       return SWITCH_LOG_INVALID -1;
+               } else if (x < 0) {
+                       return 0;
+               } else {
+                       return x;
+               }
+       }
+
+
        for (x = 0;; x++) {
                if (!LEVELS[x]) {
                        break;
index 4d1532df1d5d463107068551f2fb0a7a015bd807..31b182ebde2a42a8d934c0200f6c7ce9a923e5ec 100644 (file)
@@ -690,6 +690,10 @@ SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str)
        const char *p;
        switch_bool_t r = SWITCH_TRUE;
 
+       if (*str == '-' || *str == '+') {
+               str++;
+       }
+
        for (p = str; p && *p; p++) {
                if (!(*p == '.' || (*p > 47 && *p < 58))) {
                        r = SWITCH_FALSE;