[asterisk-commits] branch oej/test-this-branch r12480 - in /team/oej/test-this-branch: ./ includ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Mar 9 10:51:22 MST 2006


Author: oej
Date: Thu Mar  9 11:51:18 2006
New Revision: 12480

URL: http://svn.digium.com/view/asterisk?rev=12480&view=rev
Log:
Issue #6524 - Mute logging in remote Asterisk console with "set mute" command.

Modified:
    team/oej/test-this-branch/README.test-this-branch
    team/oej/test-this-branch/asterisk.c
    team/oej/test-this-branch/cli.c
    team/oej/test-this-branch/include/asterisk/logger.h
    team/oej/test-this-branch/logger.c

Modified: team/oej/test-this-branch/README.test-this-branch
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/README.test-this-branch?rev=12480&r1=12479&r2=12480&view=diff
==============================================================================
--- team/oej/test-this-branch/README.test-this-branch (original)
+++ team/oej/test-this-branch/README.test-this-branch Thu Mar  9 11:51:18 2006
@@ -46,6 +46,7 @@
 - LDAP realtime driver (mguesdon, #5768)
   See doc/rt_ldap.txt!
 - PostgreSQL realtime driver (mguesdoon, #5637)
+- Mute logging in remote console (mavetju, #6524)
 
 
 Coming here soon:

Modified: team/oej/test-this-branch/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/asterisk.c?rev=12480&r1=12479&r2=12480&view=diff
==============================================================================
--- team/oej/test-this-branch/asterisk.c (original)
+++ team/oej/test-this-branch/asterisk.c Thu Mar  9 11:51:18 2006
@@ -172,6 +172,7 @@
 	int fd;				/*!< File descriptor */
 	int p[2];			/*!< Pipe */
 	pthread_t t;			/*!< Thread of handler */
+	int mute;			/*!< Is the console muted for logs */
 };
 
 struct ast_atexit {
@@ -515,6 +516,51 @@
 }
 
 /*!
+ * mute or unmute a console from logging
+ */
+void ast_console_mute(int fd) {
+	int x;
+	for (x=0;x<AST_MAX_CONNECTS; x++) {
+		if (fd == consoles[x].fd) {
+			if (consoles[x].mute) {
+				consoles[x].mute=0;
+				ast_cli(fd, "Console is not muted anymore.\n");
+			} else {
+				consoles[x].mute=1;
+				ast_cli(fd, "Console is muted.\n");
+			}
+			return 0;
+		}
+	}
+	ast_cli(fd, "Couldn't find remote console.\n");
+}
+
+/*!
+ * log the string to all attached console clients
+ */
+static void ast_network_puts_mutable(const char *string)
+{
+	int x;
+	for (x=0; x < AST_MAX_CONNECTS; x++) {
+		if (consoles[x].mute)
+			continue;;
+		if (consoles[x].fd > -1) 
+			fdprint(consoles[x].p[1], string);
+	}
+}
+
+/*!
+ * log the string to the console, and all attached
+ * console clients
+ */
+void ast_console_puts_mutable(const char *string)
+{
+	fputs(string, stdout);
+	fflush(stdout);
+	ast_network_puts_mutable(string);
+}
+
+/*!
  * write the string to all attached console clients
  */
 static void ast_network_puts(const char *string)
@@ -545,14 +591,14 @@
 		if ((t = alloca(strlen(s) + 2))) {
 			sprintf(t, "\r%s", s);
 			if (complete)
-				ast_network_puts(t);
+				ast_network_puts_mutable(t);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory\n");
-			ast_network_puts(s);
+			ast_network_puts_mutable(s);
 		}
 	} else {
 		if (complete)
-			ast_network_puts(s);
+			ast_network_puts_mutable(s);
 	}
 }
 

Modified: team/oej/test-this-branch/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/cli.c?rev=12480&r1=12479&r2=12480&view=diff
==============================================================================
--- team/oej/test-this-branch/cli.c (original)
+++ team/oej/test-this-branch/cli.c Thu Mar  9 11:51:18 2006
@@ -121,6 +121,11 @@
 "       no messages should be displayed. Equivalent to -d[d[d...]]\n"
 "       on startup.\n";
 
+static char set_mute_help[] = 
+"Usage: set mute\n"
+"       Disables logging output to the current console, making it possible to gather\n"
+"       information without being disturbed by scrolling lines.\n";
+
 static char softhangup_help[] =
 "Usage: soft hangup <channel>\n"
 "       Request that a channel be hung up. The hangup takes effect\n"
@@ -216,6 +221,14 @@
 		ast_cli(fd, "Core debug is at least %d\n", option_debug);
 	else if (oldval > 0 && option_debug == 0)
 		ast_cli(fd, "Core debug is now OFF\n");
+	return RESULT_SUCCESS;
+}
+
+static int handle_set_mute(int fd, int argc, char *argv[])
+{
+	if (argc != 2)
+		return RESULT_SHOWUSAGE;
+	ast_console_mute(fd);
 	return RESULT_SUCCESS;
 }
 
@@ -930,6 +943,7 @@
 	{ { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch_4 },
 	{ { "reload", NULL }, handle_reload, "Reload configuration", reload_help, complete_mod_2 },
 	{ { "set", "debug", NULL }, handle_set_debug, "Set level of debug chattiness", set_debug_help },
+	{ { "set", "mute", NULL }, handle_set_mute, "Disable logging output to a console", set_mute_help },
 	{ { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
 	{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },
 	{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help, complete_show_channels },

Modified: team/oej/test-this-branch/include/asterisk/logger.h
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/include/asterisk/logger.h?rev=12480&r1=12479&r2=12480&view=diff
==============================================================================
--- team/oej/test-this-branch/include/asterisk/logger.h (original)
+++ team/oej/test-this-branch/include/asterisk/logger.h Thu Mar  9 11:51:18 2006
@@ -81,6 +81,8 @@
 extern int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
 extern int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
 extern void ast_console_puts(const char *string);
+extern void ast_console_puts_mutable(const char *string);
+extern void ast_console_mute(int fd);
 
 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
 

Modified: team/oej/test-this-branch/logger.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/logger.c?rev=12480&r1=12479&r2=12480&view=diff
==============================================================================
--- team/oej/test-this-branch/logger.c (original)
+++ team/oej/test-this-branch/logger.c Thu Mar  9 11:51:18 2006
@@ -754,11 +754,11 @@
 						term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
 						term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
 					
-					ast_console_puts(buf);
+					ast_console_puts_mutable(buf);
 					va_start(ap, fmt);
 					vsnprintf(buf, sizeof(buf), fmt, ap);
 					va_end(ap);
-					ast_console_puts(buf);
+					ast_console_puts_mutable(buf);
 				}
 			/* File channels */
 			} else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {



More information about the asterisk-commits mailing list