[asterisk-commits] rmudgett: branch rmudgett/ast_verb r404908 - in /team/rmudgett/ast_verb: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 3 17:11:42 CST 2014


Author: rmudgett
Date: Fri Jan  3 17:11:37 2014
New Revision: 404908

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404908
Log:
Initial BUGBUG notes for ast_verb

Modified:
    team/rmudgett/ast_verb/include/asterisk/logger.h
    team/rmudgett/ast_verb/main/asterisk.c
    team/rmudgett/ast_verb/main/cli.c
    team/rmudgett/ast_verb/main/manager.c

Modified: team/rmudgett/ast_verb/include/asterisk/logger.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/include/asterisk/logger.h?view=diff&rev=404908&r1=404907&r2=404908
==============================================================================
--- team/rmudgett/ast_verb/include/asterisk/logger.h (original)
+++ team/rmudgett/ast_verb/include/asterisk/logger.h Fri Jan  3 17:11:37 2014
@@ -87,21 +87,29 @@
 
 void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
 
-/*! Send a verbose message (based on verbose level)
- *	\brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
- *	ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
- *	This will print the message to the console if the verbose level is set to a level >= 3
- *	Note the absence of a comma after the VERBOSE_PREFIX_3.  This is important.
- *	VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
- *  \version 11 added level parameter
+/*!
+ * \brief Send a verbose message (based on verbose level)
+ *
+ * \details This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
+ *
+ * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
+ *
+ * This will print the message to the console if the verbose level is set to a level >= 3
+ *
+ * Note the absence of a comma after the VERBOSE_PREFIX_3.  This is important.
+ * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
+ *
+ * \version 11 added level parameter
  */
 void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...);
 
-/*! Send a verbose message (based on verbose level) with deliberately specified callid
- *  \brief just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used
- *  for the log without needing to bind it to a thread. NULL is a valid argument for this function and will
- *  allow you to specify that a log will never display a call id even when there is a call id bound to the
- *  thread.
+/*!
+ * \brief Send a verbose message (based on verbose level) with deliberately specified callid
+ *
+ * \details just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used
+ * for the log without needing to bind it to a thread. NULL is a valid argument for this function and will
+ * allow you to specify that a log will never display a call id even when there is a call id bound to the
+ * thread.
  */
 void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...);
 

Modified: team/rmudgett/ast_verb/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/main/asterisk.c?view=diff&rev=404908&r1=404907&r2=404908
==============================================================================
--- team/rmudgett/ast_verb/main/asterisk.c (original)
+++ team/rmudgett/ast_verb/main/asterisk.c Fri Jan  3 17:11:37 2014
@@ -1320,6 +1320,17 @@
 		fds[1].events = POLLIN;
 		fds[1].revents = 0;
 
+/*
+ * BUGBUG this is the thread running the remote console on the main process.
+ *
+ * Need to have this thread keep track of its option_verbose value.
+ *
+ * Need to have this thread register/unregister its option_verbose value
+ * to update the global max verbose setting.
+ *
+ * Need to have ast_cli_command_multiple_full() processing of "core set verbose"
+ * updated to deal with different threads.
+ */
 		res = ast_poll(fds, 2, -1);
 		if (res < 0) {
 			if (errno != EINTR)
@@ -2041,6 +2052,7 @@
 	printf("%s", term_end());
 	fflush(stdout);
 
+/* BUGBUG this is the main console CLI command handler.  Run by the main() thread. */
 	/* Called when readline data is available */
 	if (!ast_all_zeros(s))
 		ast_el_add_history(s);
@@ -2073,38 +2085,54 @@
 		else
 			ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
 		ret = 1;
-	} else if (strncasecmp(s, "core set verbose ", 17) == 0) {
-		int old_verbose = option_verbose;
-		if (strncasecmp(s + 17, "atleast ", 8) == 0) {
-			int tmp;
-			if (sscanf(s + 25, "%d", &tmp) != 1) {
-				fprintf(stderr, "Usage: core set verbose [atleast] <level>\n");
-			} else {
-				if (tmp > option_verbose) {
-					option_verbose = tmp;
-				}
-				if (old_verbose != option_verbose) {
-					fprintf(stdout, "Set remote console verbosity from %d to %d\n", old_verbose, option_verbose);
-				} else {
-					fprintf(stdout, "Verbosity level unchanged.\n");
-				}
-			}
-		} else {
-			if (sscanf(s + 17, "%d", &option_verbose) != 1) {
-				fprintf(stderr, "Usage: core set verbose [atleast] <level>\n");
-			} else {
-				if (old_verbose != option_verbose) {
-					fprintf(stdout, "Set remote console verbosity to %d\n", option_verbose);
-				} else {
-					fprintf(stdout, "Verbosity level unchanged.\n");
-				}
-			}
-		}
-		ret = 1;
 	} else if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
 	    (s[4] == '\0' || isspace(s[4]))) {
 		quit_handler(0, SHUTDOWN_FAST, 0);
 		ret = 1;
+	} else if (s[0]) {
+		char *shrunk = ast_strdupa(s);
+		char *cur;
+		char *prev;
+
+		/*
+		 * Remove duplicate spaces from shrunk for matching purposes.
+		 *
+		 * shrunk has at least one character in it to start with or we
+		 * couldn't get here.
+		 */
+		for (prev = shrunk, cur = shrunk + 1; *cur; ++cur) {
+			if (*prev == ' ' && *cur == ' ') {
+				/* Skip repeated space delimiter. */
+				continue;
+			}
+			*++prev = *cur;
+		}
+		*++prev = '\0';
+
+		if (strncasecmp(shrunk, "core set verbose ", 17) == 0) {
+			int verbose_new;
+
+			/*
+			 * We need to still set the rasterisk option_verbose in case we are
+			 * talking to an earlier version which doesn't prefilter verbose
+			 * levels.  This is really a compromise as we should always take
+			 * what the server sends.
+			 */
+
+			if (strncasecmp(shrunk + 17, "atleast ", 8) == 0) {
+				if (sscanf(shrunk + 25, "%30d", &verbose_new) == 1) {
+					if (verbose_new > option_verbose) {
+						option_verbose = verbose_new;
+					}
+				}
+			} else if (strncasecmp(shrunk + 17, "off", 3) == 0) {
+				option_verbose = 0;
+			} else {
+				if (sscanf(shrunk + 17, "%30d", &verbose_new) == 1) {
+					option_verbose = verbose_new;
+				}
+			}
+		}
 	}
 
 	return ret;
@@ -2990,6 +3018,24 @@
 	char *ebuf;
 	int num = 0;
 
+/*
+ * BUGBUG could make rasterisk send "core set verbose <level>" when it connects to support the -v and asterisk.conf verbose options.
+ *
+ * Possibly change the command to accept "core set verbose r<level>" to make
+ * it quiet and to make earlier versions of asterisk fail to set the level
+ * on the main console.
+ *
+ * Don't send the verbose command on connect if option_verbose is zero
+ * for rasterisk connections since that will be the default.
+ *
+ * BUGBUG need to set option_verbose = 0 if -x is specified.
+ */
+	/*
+	 * Remote console cannot support -v option since that is set by
+	 * the Asterisk server process.
+	 */
+	option_verbose = 0;
+
 	memset(&sig_flags, 0, sizeof(sig_flags));
 	signal(SIGINT, __remote_quit_handler);
 	signal(SIGTERM, __remote_quit_handler);
@@ -3521,6 +3567,7 @@
 		return;
 	}
 
+/* BUGBUG this is to execute CLI commands on startup.  Run by main() thread. */
 	for (v = ast_variable_browse(cfg, "startup_commands"); v; v = v->next) {
 		if (ast_true(v->value))
 			ast_cli_command(fd, v->name);

Modified: team/rmudgett/ast_verb/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/main/cli.c?view=diff&rev=404908&r1=404907&r2=404908
==============================================================================
--- team/rmudgett/ast_verb/main/cli.c (original)
+++ team/rmudgett/ast_verb/main/cli.c Fri Jan  3 17:11:37 2014
@@ -386,6 +386,7 @@
 	return NULL;
 }
 
+/* BUGBUG need to split this command in two.  verbose cannot support by module anymore. */
 static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	int oldval;

Modified: team/rmudgett/ast_verb/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/main/manager.c?view=diff&rev=404908&r1=404907&r2=404908
==============================================================================
--- team/rmudgett/ast_verb/main/manager.c (original)
+++ team/rmudgett/ast_verb/main/manager.c Fri Jan  3 17:11:37 2014
@@ -3976,6 +3976,12 @@
 	if (!ast_strlen_zero(id)) {
 		astman_append(s, "ActionID: %s\r\n", id);
 	}
+/*
+ * BUGBUG AMI CLI command execution.  Can only affect the main console.
+ *
+ * What remote console could it affect?  It's certainly not its own console.
+ * It could affect the logging verbose level.  But then which logging file?
+ */
 	/* FIXME: Wedge a ActionID response in here, waiting for later changes */
 	ast_cli_command(fd, cmd);	/* XXX need to change this to use a FILE * */
 	/* Determine number of characters available */




More information about the asterisk-commits mailing list