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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 8 11:16:43 CST 2014


Author: rmudgett
Date: Wed Jan  8 11:16:38 2014
New Revision: 405132

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405132
Log:
Make the network_verboser() filter verbose levels.

Modified:
    team/rmudgett/ast_verb/include/asterisk/logger.h
    team/rmudgett/ast_verb/main/asterisk.c
    team/rmudgett/ast_verb/main/logger.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=405132&r1=405131&r2=405132
==============================================================================
--- team/rmudgett/ast_verb/include/asterisk/logger.h (original)
+++ team/rmudgett/ast_verb/include/asterisk/logger.h Wed Jan  8 11:16:38 2014
@@ -123,6 +123,14 @@
 int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
 int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
 
+/*
+ * These gymnastics are due to platforms which designate char as unsigned by
+ * default.  Level is the negative character -- offset by 1, because \0 is
+ * the string terminator.
+ */
+#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
+#define VERBOSE_HASMAGIC(x)	(*(signed char *) (x) < 0)
+
 void ast_console_puts(const char *string);
 
 /*!

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=405132&r1=405131&r2=405132
==============================================================================
--- team/rmudgett/ast_verb/main/asterisk.c (original)
+++ team/rmudgett/ast_verb/main/asterisk.c Wed Jan  8 11:16:38 2014
@@ -1188,29 +1188,33 @@
 }
 
 /*!
- * \brief log the string to all attached console clients
+ * \brief log the string to all attached network console clients
  */
 static void ast_network_puts_mutable(const char *string, int level)
 {
 	int x;
-	for (x = 0;x < AST_MAX_CONNECTS; x++) {
-		if (consoles[x].mute)
+
+	for (x = 0; x < AST_MAX_CONNECTS; ++x) {
+		if (consoles[x].fd < 0
+			|| consoles[x].mute
+			|| consoles[x].levels[level]) {
 			continue;
-		if (consoles[x].fd > -1) {
-			if (!consoles[x].levels[level])
-				fdprint(consoles[x].p[1], string);
-		}
+		}
+		fdprint(consoles[x].p[1], string);
 	}
 }
 
 /*!
- * \brief log the string to the console, and all attached
- * console clients
+ * \brief log the string to the root console, and all attached
+ * network console clients
  */
 void ast_console_puts_mutable(const char *string, int level)
 {
+	/* Send to the root console */
 	fputs(string, stdout);
 	fflush(stdout);
+
+	/* Send to any network console clients */
 	ast_network_puts_mutable(string, level);
 }
 
@@ -1220,27 +1224,45 @@
 static void ast_network_puts(const char *string)
 {
 	int x;
-	for (x = 0; x < AST_MAX_CONNECTS; x++) {
-		if (consoles[x].fd > -1)
-			fdprint(consoles[x].p[1], string);
+
+	for (x = 0; x < AST_MAX_CONNECTS; ++x) {
+		if (consoles[x].fd < 0) {
+			continue;
+		}
+		fdprint(consoles[x].p[1], string);
 	}
 }
 
 /*!
- * write the string to the console, and all attached
- * console clients
+ * write the string to the root console, and all attached
+ * network console clients
  */
 void ast_console_puts(const char *string)
 {
+	/* Send to the root console */
 	fputs(string, stdout);
 	fflush(stdout);
+
+	/* Send to any network console clients */
 	ast_network_puts(string);
 }
 
-static void network_verboser(const char *s)
-{
-/* BUGBUG change this to put to each network connection if the verbose level is allowed. */
-	ast_network_puts_mutable(s, __LOG_VERBOSE);
+static void network_verboser(const char *string)
+{
+	int x;
+	int verb_level;
+
+	/* Send to any network console clients if client verbocity allows. */
+	verb_level = VERBOSE_MAGIC2LEVEL(string);
+	for (x = 0; x < AST_MAX_CONNECTS; ++x) {
+		if (consoles[x].fd < 0
+			|| consoles[x].mute
+			|| consoles[x].levels[__LOG_VERBOSE]
+			|| consoles[x].option_verbose < verb_level) {
+			continue;
+		}
+		fdprint(consoles[x].p[1], string);
+	}
 }
 
 static pthread_t lthread;
@@ -1946,12 +1968,6 @@
 }
 
 AST_THREADSTORAGE_CUSTOM(console_state, console_state_init, ast_free_ptr);
-
-/* These gymnastics are due to platforms which designate char as unsigned by
- * default. Level is the negative character -- offset by 1, because \0 is the
- * EOS delimiter. */
-#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
-#define VERBOSE_HASMAGIC(x)	(*(signed char *) (x) < 0)
 
 static int console_print(const char *s, int local)
 {

Modified: team/rmudgett/ast_verb/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/main/logger.c?view=diff&rev=405132&r1=405131&r2=405132
==============================================================================
--- team/rmudgett/ast_verb/main/logger.c (original)
+++ team/rmudgett/ast_verb/main/logger.c Wed Jan  8 11:16:38 2014
@@ -1034,12 +1034,6 @@
 	syslog(syslog_level, "%s", buf);
 }
 
-/* These gymnastics are due to platforms which designate char as unsigned by
- * default. Level is the negative character -- offset by 1, because \0 is the
- * EOS delimiter. */
-#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
-#define VERBOSE_HASMAGIC(x)	(*(signed char *) (x) < 0)
-
 /*! \brief Print a normal log message to the channels */
 static void logger_print_normal(struct logmsg *logmsg)
 {

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=405132&r1=405131&r2=405132
==============================================================================
--- team/rmudgett/ast_verb/main/manager.c (original)
+++ team/rmudgett/ast_verb/main/manager.c Wed Jan  8 11:16:38 2014
@@ -3976,12 +3976,6 @@
 	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