[Asterisk-cvs] asterisk asterisk.c,1.123,1.124 cli.c,1.52,1.53

markster at lists.digium.com markster at lists.digium.com
Mon Sep 13 14:17:35 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv14139

Modified Files:
	asterisk.c cli.c 
Log Message:
Add set debug option, make output for set verbose better (bug #2428)


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- asterisk.c	7 Sep 2004 15:02:53 -0000	1.123
+++ asterisk.c	13 Sep 2004 18:19:15 -0000	1.124
@@ -1404,6 +1404,8 @@
 		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")) 

Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- cli.c	3 Sep 2004 14:02:12 -0000	1.52
+++ cli.c	13 Sep 2004 18:19:15 -0000	1.53
@@ -89,7 +89,14 @@
 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_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 @@
 		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 @@
 	{ { "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 },




More information about the svn-commits mailing list