Author: anthm Date: Tue Jun 9 14:52:07 2009 New Revision: 13735 Log: add sofia tracelevel <level> and tracelevel param in <settings> Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_log.c freeswitch/trunk/src/switch_utils.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Jun 9 14:52:07 2009 @@ -2441,6 +2441,12 @@ 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]); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue Jun 9 14:52:07 2009 @@ -274,6 +274,7 @@ int debug_presence; int auto_restart; int auto_nat; + int tracelevel; }; extern struct mod_sofia_globals mod_sofia_globals; Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Jun 9 14:52:07 2009 @@ -1003,9 +1003,9 @@ 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 @@ 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); Modified: freeswitch/trunk/src/switch_log.c ============================================================================== --- freeswitch/trunk/src/switch_log.c (original) +++ freeswitch/trunk/src/switch_log.c Tue Jun 9 14:52:07 2009 @@ -120,6 +120,19 @@ 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; Modified: freeswitch/trunk/src/switch_utils.c ============================================================================== --- freeswitch/trunk/src/switch_utils.c (original) +++ freeswitch/trunk/src/switch_utils.c Tue Jun 9 14:52:07 2009 @@ -690,6 +690,10 @@ 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;