dect
/
asterisk
Archived
13
0
Fork 0

Add set debug option, make output for set verbose better (bug #2428)

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3771 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
markster 2004-09-13 18:19:15 +00:00
parent b31718e484
commit d905f33e0b
2 changed files with 46 additions and 2 deletions

View File

@ -1404,6 +1404,8 @@ static void ast_remotecontrol(char * data)
pid = -1;
snprintf(tmp, sizeof(tmp), "set verbose atleast %d", option_verbose);
fdprint(ast_consock, tmp);
snprintf(tmp, sizeof(tmp), "set debug atleast %d", option_debug);
fdprint(ast_consock, tmp);
ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);
remotehostname = hostname;
if (getenv("HOME"))

46
cli.c
View File

@ -89,7 +89,14 @@ static char reload_help[] =
static char set_verbose_help[] =
"Usage: set verbose <level>\n"
" Sets level of verbose messages to be displayed. 0 means\n"
" no messages should be displayed.\n";
" no messages should be displayed. Equivalent to -v[v[v...]]\n"
" on startup\n";
static char set_debug_help[] =
"Usage: set debug <level>\n"
" Sets level of core debug messages to be displayed. 0 means\n"
" no messages should be displayed. Equivalent to -d[d[d...]]\n"
" on startup.\n";
static char softhangup_help[] =
"Usage: soft hangup <channel>\n"
@ -122,12 +129,14 @@ static int handle_reload(int fd, int argc, char *argv[])
static int handle_set_verbose(int fd, int argc, char *argv[])
{
int val;
int val = 0;
int oldval = 0;
/* Has a hidden 'at least' argument */
if ((argc != 3) && (argc != 4))
return RESULT_SHOWUSAGE;
if ((argc == 4) && strcasecmp(argv[2], "atleast"))
return RESULT_SHOWUSAGE;
oldval = option_verbose;
if (argc == 3)
option_verbose = atoi(argv[2]);
else {
@ -135,6 +144,38 @@ static int handle_set_verbose(int fd, int argc, char *argv[])
if (val > option_verbose)
option_verbose = val;
}
if (oldval != option_verbose && option_verbose > 0)
ast_cli(fd, "Verbosity was %d and is now %d\n", oldval, option_verbose);
else if (oldval > 0 && option_verbose > 0)
ast_cli(fd, "Verbosity is atleast %d\n", option_verbose);
else if (oldval > 0 && option_debug == 0)
ast_cli(fd, "Verbosity is now OFF\n");
return RESULT_SUCCESS;
}
static int handle_set_debug(int fd, int argc, char *argv[])
{
int val = 0;
int oldval = 0;
/* Has a hidden 'at least' argument */
if ((argc != 3) && (argc != 4))
return RESULT_SHOWUSAGE;
if ((argc == 4) && strcasecmp(argv[2], "atleast"))
return RESULT_SHOWUSAGE;
oldval = option_debug;
if (argc == 3)
option_debug = atoi(argv[2]);
else {
val = atoi(argv[3]);
if (val > option_debug)
option_debug = val;
}
if (oldval != option_debug && option_debug > 0)
ast_cli(fd, "Core debug was %d and is now %d\n", oldval, option_debug);
else if (oldval > 0 && option_debug > 0)
ast_cli(fd, "Core debug is atleast %d\n", option_debug);
else if (oldval > 0 && option_debug == 0)
ast_cli(fd, "Core debug is now OFF\n");
return RESULT_SUCCESS;
}
@ -652,6 +693,7 @@ static struct ast_cli_entry builtins[] = {
{ { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
{ { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch_4 },
{ { "reload", NULL }, handle_reload, "Reload configuration", reload_help },
{ { "set", "debug", NULL }, handle_set_debug, "Set level of debug chattiness", set_debug_help },
{ { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },