From 2e1e0735fe84ddb5536687f2bf5948ff94640423 Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Thu, 14 Feb 2013 18:47:56 +0000 Subject: Revamp of terminal color codes The core module related to coloring terminal output was old and needed some love. The main thing here was an attempt to get rid of the obscene number of stack-local buffers that were allocated for no other reason than to colorize some output. Instead, this uses a simple trick to allocate several buffers within threadlocal storage, then automatically rotates between them, so that you can make multiple calls to the colorization routine within one function and not need to allocate multiple buffers. Review: https://reviewboard.asterisk.org/r/2241/ Patches: bug.patch uploaded by Tilghman Lesher git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381448 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_queue.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/app_queue.c b/apps/app_queue.c index f02ed4407..6e410002a 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -105,6 +105,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/callerid.h" #include "asterisk/cel.h" #include "asterisk/data.h" +#include "asterisk/term.h" /* Define, to debug reference counts on queues, without debugging reference counts on queue members */ /* #define REF_DEBUG_ONLY_QUEUES */ @@ -8312,11 +8313,14 @@ static char *__queues_show(struct mansession *s, int fd, int argc, const char * ast_str_append(&out, 0, " (ringinuse %s)", mem->ringinuse ? "enabled" : "disabled"); - ast_str_append(&out, 0, "%s%s%s (%s)", - mem->dynamic ? " (dynamic)" : "", - mem->realtime ? " (realtime)" : "", - mem->paused ? " (paused)" : "", - ast_devstate2str(mem->status)); + ast_str_append(&out, 0, "%s%s%s%s%s%s%s%s%s (%s%s%s)", + mem->dynamic ? ast_term_color(COLOR_CYAN, COLOR_BLACK) : "", mem->dynamic ? " (dynamic)" : "", ast_term_reset(), + mem->realtime ? ast_term_color(COLOR_MAGENTA, COLOR_BLACK) : "", mem->realtime ? " (realtime)" : "", ast_term_reset(), + mem->paused ? ast_term_color(COLOR_BROWN, COLOR_BLACK) : "", mem->paused ? " (paused)" : "", ast_term_reset(), + ast_term_color( + mem->status == AST_DEVICE_UNAVAILABLE || mem->status == AST_DEVICE_UNKNOWN ? + COLOR_RED : COLOR_GREEN, COLOR_BLACK), + ast_devstate2str(mem->status), ast_term_reset()); if (mem->calls) { ast_str_append(&out, 0, " has taken %d calls (last was %ld secs ago)", mem->calls, (long) (time(NULL) - mem->lastcall)); -- cgit v1.2.3