mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 04:31:50 +00:00
handle invalid log level strings. (FSCORE-69)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6604 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -565,8 +565,13 @@ SWITCH_STANDARD_API(ctl_function)
|
||||
} else {
|
||||
arg = -1;
|
||||
}
|
||||
switch_core_session_ctl(SCSC_LOGLEVEL, &arg);
|
||||
stream->write_function(stream, "+OK log level: %s [%d]\n", switch_log_level2str(arg), arg);
|
||||
|
||||
if (arg == -1 || arg == SWITCH_LOG_INVALID) {
|
||||
stream->write_function(stream, "-ERR syntax error, log level not set!\n");
|
||||
} else {
|
||||
switch_core_session_ctl(SCSC_LOGLEVEL, &arg);
|
||||
stream->write_function(stream, "+OK log level: %s [%d]\n", switch_log_level2str(arg), arg);
|
||||
}
|
||||
} else if (!strcasecmp(argv[0], "last_sps")) {
|
||||
switch_core_session_ctl(SCSC_LAST_SPS, &arg);
|
||||
stream->write_function(stream, "+OK last sessions per second: %d\n", arg);
|
||||
|
||||
@@ -635,6 +635,9 @@ SWITCH_STANDARD_APP(log_function)
|
||||
} else {
|
||||
log_str = level;
|
||||
}
|
||||
if (ltype == SWITCH_LOG_INVALID) {
|
||||
ltype = SWITCH_LOG_DEBUG;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, ltype, "%s\n", log_str);
|
||||
switch_safe_free(level);
|
||||
|
||||
@@ -811,6 +811,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
} else if (!strncasecmp(cmd, "log", 3)) {
|
||||
|
||||
char *level_s;
|
||||
switch_log_level_t ltype = SWITCH_LOG_DEBUG;
|
||||
|
||||
//pull off the first newline/carriage return
|
||||
strip_cr(cmd);
|
||||
@@ -824,11 +825,12 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
level_s++;
|
||||
}
|
||||
//see if we lined up on an argument or not
|
||||
if (switch_strlen_zero(level_s)) {
|
||||
level_s = "debug";
|
||||
if (!switch_strlen_zero(level_s)) {
|
||||
ltype = switch_log_str2level(level_s);
|
||||
}
|
||||
|
||||
if ((listener->level = switch_log_str2level(level_s))) {
|
||||
if (ltype && ltype != SWITCH_LOG_INVALID) {
|
||||
listener->level = ltype;
|
||||
switch_set_flag(listener, LFLAG_LOG);
|
||||
snprintf(reply, reply_len, "+OK log level %s [%d]", level_s, listener->level);
|
||||
} else {
|
||||
|
||||
@@ -3002,6 +3002,9 @@ static JSBool js_log(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, j
|
||||
if (argc > 1) {
|
||||
if ((level_str = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
|
||||
level = switch_log_str2level(level_str);
|
||||
if (level == SWITCH_LOG_INVALID) {
|
||||
level = SWITCH_LOG_DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[1])))) {
|
||||
|
||||
@@ -76,10 +76,10 @@ static void add_mapping(char *var, char *val, int cumlative)
|
||||
uint32_t l = switch_log_str2level(val);
|
||||
uint32_t i;
|
||||
|
||||
assert(l < 10);
|
||||
|
||||
for (i = 0; i <= l; i++) {
|
||||
m |= (1 << i);
|
||||
if (l < 10) {
|
||||
for (i = 0; i <= l; i++) {
|
||||
m |= (1 << i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m = switch_log_str2mask(val);
|
||||
@@ -227,8 +227,12 @@ SWITCH_STANDARD_API(console_api_function)
|
||||
level = switch_log_str2level(argv[1]);
|
||||
}
|
||||
|
||||
hard_log_level = level;
|
||||
stream->write_function(stream, "+OK console log level set to %s\n", switch_log_level2str(hard_log_level));
|
||||
if (level == SWITCH_LOG_INVALID) {
|
||||
stream->write_function(stream, "-ERR syntax error, console log level not set!\n");
|
||||
} else {
|
||||
hard_log_level = level;
|
||||
stream->write_function(stream, "+OK console log level set to %s\n", switch_log_level2str(hard_log_level));
|
||||
}
|
||||
goto end;
|
||||
} else if (!strcasecmp(argv[0], "colorize")) {
|
||||
COLORIZE = switch_true(argv[1]);
|
||||
|
||||
Reference in New Issue
Block a user