Browse Source

TT#97301 allow printing and setting of individual log levels

Change-Id: I3ac399a7041aa04847fd4a35a9c0f12a2a0a8ce3
pull/1164/head
Richard Fuchs 5 years ago
parent
commit
c69415ba45
2 changed files with 37 additions and 8 deletions
  1. +32
    -6
      daemon/cli.c
  2. +5
    -2
      utils/rtpengine-ctl

+ 32
- 6
daemon/cli.c View File

@ -83,6 +83,7 @@ static void cli_incoming_list_silenttimeout(str *instr, struct cli_writer *cw);
static void cli_incoming_list_offertimeout(str *instr, struct cli_writer *cw); static void cli_incoming_list_offertimeout(str *instr, struct cli_writer *cw);
static void cli_incoming_list_finaltimeout(str *instr, struct cli_writer *cw); static void cli_incoming_list_finaltimeout(str *instr, struct cli_writer *cw);
static void cli_incoming_list_loglevel(str *instr, struct cli_writer *cw); static void cli_incoming_list_loglevel(str *instr, struct cli_writer *cw);
static void cli_incoming_list_loglevels(str *instr, struct cli_writer *cw);
static void cli_incoming_list_redisallowederrors(str *instr, struct cli_writer *cw); static void cli_incoming_list_redisallowederrors(str *instr, struct cli_writer *cw);
static void cli_incoming_list_redisdisabletime(str *instr, struct cli_writer *cw); static void cli_incoming_list_redisdisabletime(str *instr, struct cli_writer *cw);
static void cli_incoming_list_redisconnecttimeout(str *instr, struct cli_writer *cw); static void cli_incoming_list_redisconnecttimeout(str *instr, struct cli_writer *cw);
@ -137,6 +138,7 @@ static const cli_handler_t cli_list_handlers[] = {
{ "silenttimeout", cli_incoming_list_silenttimeout }, { "silenttimeout", cli_incoming_list_silenttimeout },
{ "offertimeout", cli_incoming_list_offertimeout }, { "offertimeout", cli_incoming_list_offertimeout },
{ "finaltimeout", cli_incoming_list_finaltimeout }, { "finaltimeout", cli_incoming_list_finaltimeout },
{ "loglevels", cli_incoming_list_loglevels },
{ "loglevel", cli_incoming_list_loglevel }, { "loglevel", cli_incoming_list_loglevel },
{ "redisallowederrors", cli_incoming_list_redisallowederrors }, { "redisallowederrors", cli_incoming_list_redisallowederrors },
{ "redisdisabletime", cli_incoming_list_redisdisabletime }, { "redisdisabletime", cli_incoming_list_redisdisabletime },
@ -1189,8 +1191,23 @@ fail:
} }
static void cli_incoming_list_loglevel(str *instr, struct cli_writer *cw) { static void cli_incoming_list_loglevel(str *instr, struct cli_writer *cw) {
if (instr && instr->len)
str_shift(instr, 1);
for (unsigned int i = 0; i < num_log_levels; i++) {
if (instr && instr->len) {
if (str_cmp(instr, log_level_names[i]))
continue;
}
if (instr && instr->len)
cw->cw_printf(cw, "%i\n", __get_log_level(i));
else
cw->cw_printf(cw, "%s = %i\n", log_level_names[i], __get_log_level(i));
}
}
static void cli_incoming_list_loglevels(str *instr, struct cli_writer *cw) {
for (unsigned int i = 0; i < num_log_levels; i++) for (unsigned int i = 0; i < num_log_levels; i++)
cw->cw_printf(cw, "%s = %i\n", log_level_names[i], __get_log_level(i));
cw->cw_printf(cw, "%s\n", log_level_names[i]);
} }
static void cli_incoming_set_loglevel(str *instr, struct cli_writer *cw) { static void cli_incoming_set_loglevel(str *instr, struct cli_writer *cw) {
int nl; int nl;
@ -1200,15 +1217,24 @@ static void cli_incoming_set_loglevel(str *instr, struct cli_writer *cw) {
return; return;
} }
nl = atoi(instr->s);
if (nl < 1 || nl > 7) {
cw->cw_printf(cw, "Invalid log level '%s', must be number between 1 and 7\n",
instr->s);
str subsys = STR_NULL;
if (instr->len && (instr->s[0] < '0' || instr->s[0] > '9'))
str_token_sep(&subsys, instr, ' ');
if (!instr->len) {
cw->cw_printf(cw, "%s\n", "More parameters required.");
return; return;
} }
for (unsigned int i = 0; i < num_log_levels; i++)
nl = atoi(instr->s);
for (unsigned int i = 0; i < num_log_levels; i++) {
if (subsys.len) {
if (str_cmp(&subsys, log_level_names[i]))
continue;
}
g_atomic_int_set(&rtpe_config.common.log_levels[i], nl); g_atomic_int_set(&rtpe_config.common.log_levels[i], nl);
}
cw->cw_printf(cw, "Success setting loglevel to %i\n", nl); cw->cw_printf(cw, "Success setting loglevel to %i\n", nl);
} }


+ 5
- 2
utils/rtpengine-ctl View File

@ -101,7 +101,9 @@ sub showusage {
print " silenttimeout : print silent-timeout parameter\n"; print " silenttimeout : print silent-timeout parameter\n";
print " finaltimeout : print final-timeout parameter\n"; print " finaltimeout : print final-timeout parameter\n";
print " offertimeout : print offer-timeout parameter\n"; print " offertimeout : print offer-timeout parameter\n";
print " loglevel : print current log level\n";
print " loglevels : print available log levels\n";
print " loglevel : print current log levels\n";
print " loglevel <system> : print one current log level\n";
print " redisallowederrors : print redis-allowed-errors parameter\n"; print " redisallowederrors : print redis-allowed-errors parameter\n";
print " redisdisabletime : print redis-disable-time parameter\n"; print " redisdisabletime : print redis-disable-time parameter\n";
print " redisconnecttimeout : print redis-connect-timeout parameter\n"; print " redisconnecttimeout : print redis-connect-timeout parameter\n";
@ -129,7 +131,8 @@ sub showusage {
print " silenttimeout <uint> : set the --silent-timeout parameter \n"; print " silenttimeout <uint> : set the --silent-timeout parameter \n";
print " finaltimeout <uint> : set the --final-timeout parameter \n"; print " finaltimeout <uint> : set the --final-timeout parameter \n";
print " offertimeout <uint> : set the --offer-timeout parameter \n"; print " offertimeout <uint> : set the --offer-timeout parameter \n";
print " loglevel <uint> : set the log level to new value (1-7)\n";
print " loglevel <uint> : set all log levels to new value (1-7)\n";
print " loglevel <sys> <uint> : set one log level to new value (1-7)\n";
print " redisallowederrors : set the --redis-allowed-errors parameter\n"; print " redisallowederrors : set the --redis-allowed-errors parameter\n";
print " redisdisabletime : set the --redis-disable-time parameter\n"; print " redisdisabletime : set the --redis-disable-time parameter\n";
print " redisconnecttimeout : set the --redis-connect-timeout parameter\n"; print " redisconnecttimeout : set the --redis-connect-timeout parameter\n";


Loading…
Cancel
Save