aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-26 21:47:52 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-26 21:47:52 +0000
commitb5b239798d30a54cf0c444371c55da57ee1301ff (patch)
treeb95b4a3ff52ff6be585b68f0fbe19dfdaf3965d2
parent4189c29a159b9d7d9cefdc2906da7e97dfb41d60 (diff)
Fix various problems in the addition of the ability to mute log/verbose
output to remove consoles. The prototypes added to logger.h still need doxygen documentation, as well. - Add the new command line option to the man page - make the mute option a flag instead of an int since it is only a binary option - remove useless extern keywords for prototypes added to logger.h - rename ast_console_mute() to ast_console_toggle_mute() since that is what it actually does - actually apply the mute option to newly created remote consoles instead of only working when the CLI command is used - don't imply the NO_FORK option if the mute command line option is provided - place the new CLI command in the correct place in the list which has to be in alphabetical order - Finally, clean up a few spacing issues to conform to the coding guidelines git-svn-id: http://svn.digium.com/svn/asterisk/trunk@30630 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--asterisk.83
-rw-r--r--asterisk.c22
-rw-r--r--cli.c4
-rw-r--r--include/asterisk/logger.h4
-rw-r--r--include/asterisk/options.h3
5 files changed, 20 insertions, 16 deletions
diff --git a/asterisk.8 b/asterisk.8
index b90e342ff..47b89e1fd 100644
--- a/asterisk.8
+++ b/asterisk.8
@@ -85,6 +85,9 @@ Limits the maximum load average before rejecting new calls. This can
be useful to prevent a system from being brought down by terminating
too many simultaneous calls.
.TP
+\fB-m\fR
+Disable log and verbose output to remote (-r) consoles.
+.TP
\fB-M \fIvalue\fB\fR
Limits the maximum number of calls to the specified value. This can
be useful to prevent a system from being brought down by terminating
diff --git a/asterisk.c b/asterisk.c
index 203e18560..718e0f20c 100644
--- a/asterisk.c
+++ b/asterisk.c
@@ -160,7 +160,6 @@ struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };
int option_verbose = 0; /*!< Verbosity level */
int option_debug = 0; /*!< Debug level */
-int option_mute = 0; /*!< Mute console */
double option_maxload = 0.0; /*!< Max load avg on system */
int option_maxcalls = 0; /*!< Max number of active calls */
@@ -685,15 +684,15 @@ int ast_safe_system(const char *s)
/*!
* mute or unmute a console from logging
*/
-void ast_console_mute(int fd) {
+void ast_console_toggle_mute(int fd) {
int x;
- for (x=0;x<AST_MAX_CONNECTS; x++) {
+ for (x = 0;x < AST_MAX_CONNECTS; x++) {
if (fd == consoles[x].fd) {
if (consoles[x].mute) {
- consoles[x].mute=0;
+ consoles[x].mute = 0;
ast_cli(fd, "Console is not muted anymore.\n");
} else {
- consoles[x].mute=1;
+ consoles[x].mute = 1;
ast_cli(fd, "Console is muted.\n");
}
return;
@@ -708,9 +707,9 @@ void ast_console_mute(int fd) {
static void ast_network_puts_mutable(const char *string)
{
int x;
- for (x=0;x < AST_MAX_CONNECTS; x++) {
+ for (x = 0;x < AST_MAX_CONNECTS; x++) {
if (consoles[x].mute)
- continue;;
+ continue;
if (consoles[x].fd > -1)
fdprint(consoles[x].p[1], string);
}
@@ -866,7 +865,7 @@ static void *listener(void *unused)
flags = fcntl(consoles[x].p[1], F_GETFL);
fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
consoles[x].fd = s;
- consoles[x].mute = 0;
+ consoles[x].mute = ast_opt_mute;
if (ast_pthread_create(&consoles[x].t, &attr, netconsole, &consoles[x])) {
ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
close(consoles[x].p[0]);
@@ -2073,8 +2072,8 @@ static void ast_remotecontrol(char * data)
fdprint(ast_consock, tmp);
snprintf(tmp, sizeof(tmp), "set debug atleast %d", option_debug);
fdprint(ast_consock, tmp);
- if (option_mute) {
- snprintf(tmp, sizeof(tmp), "logger mute");
+ if (ast_opt_mute) {
+ snprintf(tmp, sizeof(tmp), "log and verbose output currently muted ('logger unmute' to unmute)");
fdprint(ast_consock, tmp);
}
ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);
@@ -2396,8 +2395,7 @@ int main(int argc, char *argv[])
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
break;
case 'm':
- option_mute++;
- ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
+ ast_set_flag(&ast_options, AST_OPT_FLAG_MUTE);
break;
case 'M':
if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0))
diff --git a/cli.c b/cli.c
index dcdb05716..126f16b72 100644
--- a/cli.c
+++ b/cli.c
@@ -222,7 +222,7 @@ static int handle_logger_mute(int fd, int argc, char *argv[])
{
if (argc != 2)
return RESULT_SHOWUSAGE;
- ast_console_mute(fd);
+ ast_console_toggle_mute(fd);
return RESULT_SUCCESS;
}
@@ -928,11 +928,11 @@ static struct ast_cli_entry builtins[] = {
{ { "group", "show", "channels", NULL }, group_show_channels, "Show active channels with group(s)", group_show_channels_help},
{ { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help, complete_help },
{ { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
+ { { "logger", "mute", NULL }, handle_logger_mute, "Toggle logging output to a console", logger_mute_help },
{ { "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", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
- { { "logger", "mute", NULL }, handle_logger_mute, "Disable logging output to a console", logger_mute_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 },
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 9d00fba30..247ac8326 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -82,8 +82,8 @@ int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int re
int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
void ast_console_puts(const char *string);
-extern void ast_console_puts_mutable(const char *string);
-extern void ast_console_mute(int fd);
+void ast_console_puts_mutable(const char *string);
+void ast_console_toggle_mute(int fd);
#define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index bc4c10905..c0b8a433e 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -76,6 +76,8 @@ enum ast_option_flags {
AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20),
/*! Always fork, even if verbose or debug settings are non-zero */
AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
+ /*! Disable log/verbose output to remote consoles */
+ AST_OPT_FLAG_MUTE = (1 << 22)
};
/*! These are the options that set by default when Asterisk starts */
@@ -103,6 +105,7 @@ enum ast_option_flags {
#define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN)
#define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING)
#define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
+#define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
extern struct ast_flags ast_options;