Logger/CLI/etc.: Fix some aesthetic issues; reduce chatty verbose messages

This patch addresses some aesthetic issues in Asterisk. These are all just
minor tweaks to improve the look of the CLI when used in a variety of
settings. Specifically:
 * A number of chatty verbose messages were removed or demoted to DEBUG
   messages. Verbose messages with a verbosity level of 5 or higher were -
   if kept as verbose messages - demoted to level 4. Several messages
   that were emitted at verbose level 3 were demoted to 4, as announcement
   of dialplan applications being executed occur at level 3 (and so the
   effects of those applications should generally be less).
 * Some verbose messages that only appear when their respective 'debug'
   options are enabled were bumped up to always be displayed.
 * Prefix/timestamping of verbose messages were moved to the verboser
   handlers. This was done to prevent duplication of prefixes when the
   timestamp option (-T) is used with the CLI.
 * Verbose magic is removed from messages before being emitted to
   non-verboser handlers. This prevents the magic in multi-line verbose
   messages (such as SIP debug traces or the output of DumpChan) from
   being written to files.
 * _Slightly_ better support for the "light background" option (-W) was
   added. This includes using ast_term_quit in the output of XML
   documentation help, as well as changing the "Asterisk Ready" prompt to
   bright green on the default background (which stands a better chance of
   being displayed properly than bright white).

Review: https://reviewboard.asterisk.org/r/3547/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2014-05-28 22:54:12 +00:00
parent 812f33d222
commit fb5690ce4b
27 changed files with 124 additions and 121 deletions

View File

@@ -2068,13 +2068,14 @@ static void __remote_quit_handler(int num)
sig_flags.need_quit = 1;
}
static const char *fix_header(char *outbuf, int maxout, const char *s, char level)
static void set_header(char *outbuf, int maxout, char level)
{
const char *cmp;
char date[40];
switch (level) {
case 0: *outbuf = '\0';
return s;
case 0: cmp = NULL;
break;
case 1: cmp = VERBOSE_PREFIX_1;
break;
case 2: cmp = VERBOSE_PREFIX_2;
@@ -2085,12 +2086,20 @@ static const char *fix_header(char *outbuf, int maxout, const char *s, char leve
break;
}
if (!strncmp(s, cmp, strlen(cmp))) {
s += strlen(cmp);
if (ast_opt_timestamp) {
struct ast_tm tm;
struct timeval now = ast_tvnow();
ast_localtime(&now, &tm, NULL);
ast_strftime(date, sizeof(date), ast_logger_get_dateformat(), &tm);
}
term_color(outbuf, cmp, COLOR_GRAY, 0, maxout);
return s;
snprintf(outbuf, maxout, "%s%s%s%s%s%s",
ast_opt_timestamp ? "[" : "",
ast_opt_timestamp ? date : "",
ast_opt_timestamp ? "] " : "",
cmp ? ast_term_color(COLOR_GRAY, 0) : "",
cmp ? cmp : "",
cmp ? ast_term_reset() : "");
}
struct console_state_data {
@@ -2118,16 +2127,15 @@ static int console_print(const char *s, int local)
do {
if (VERBOSE_HASMAGIC(s)) {
/* always use the given line's level, otherwise
we'll use the last line's level */
state->verbose_line_level = VERBOSE_MAGIC2LEVEL(s);
/* move past magic */
s++;
if (local) {
s = fix_header(prefix, sizeof(prefix), s,
state->verbose_line_level);
}
set_header(prefix, sizeof(prefix), state->verbose_line_level);
} else {
*prefix = '\0';
}
@@ -2149,7 +2157,7 @@ static int console_print(const char *s, int local)
continue;
}
if (local && !ast_strlen_zero(prefix)) {
if (!ast_strlen_zero(prefix)) {
fputs(prefix, stdout);
}
@@ -2572,8 +2580,6 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args
#define ASTERISK_PROMPT "*CLI> "
#define ASTERISK_PROMPT2 "%s*CLI> "
/*!
* \brief Shutdown Asterisk CLI commands.
*
@@ -2841,10 +2847,10 @@ static char *cli_prompt(EditLine *editline)
/* Force colors back to normal at end */
ast_term_color_code(&prompt, 0, 0);
}
} else if (remotehostname) {
ast_str_set(&prompt, 0, ASTERISK_PROMPT2, remotehostname);
} else {
ast_str_set(&prompt, 0, "%s", ASTERISK_PROMPT);
ast_str_set(&prompt, 0, "%s%s",
remotehostname ? remotehostname : "",
ASTERISK_PROMPT);
}
return ast_str_buffer(prompt);
@@ -4552,9 +4558,6 @@ int main(int argc, char *argv[])
dnsmgr_start_refresh();
/* We might have the option of showing a console, but for now just
do nothing... */
ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_BRWHITE, COLOR_BLACK, "Asterisk Ready."));
if (ast_opt_no_fork) {
consolethread = pthread_self();
}
@@ -4581,6 +4584,8 @@ int main(int argc, char *argv[])
run_startup_commands();
ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_BRGREEN, 0, "Asterisk Ready."));
if (ast_opt_console) {
/* Console stuff now... */
/* Register our quit function */