[asterisk-dev] [Code Review] Revamp of terminal color codes

wdoekes reviewboard at asterisk.org
Mon Dec 10 03:29:05 CST 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2241/#review7510
-----------------------------------------------------------


I like the idea in general. I'm not immediately fond of the %s%s%s triplets though.


/trunk/main/pbx.c
<https://reviewboard.asterisk.org/r/2241/#comment14294>

    Some macros might relieve that.
    
    Instead of:
    
    ast_verb(3, "Bla: %s%d%s: %s%s%s",
             ast_term_color(COLOR_BRCYAN, 0), number, ast_term_reset(),
             ast_term_color(COLOR_BRCYAN, 0), name, ast_term_reset());
    
    Do:
    
    ast_verb(3, "Bla: %" AST_C(d) ": %" AST_C(s),
             AST_COLORED(COLOR_BRCYAN, 0, number),
             AST_COLORED(COLOR_BRCYAN, 0, name));
    
    Where AST_C(d) would become "s%d%s" and AST_COLORED would expand to the three arguments.


- wdoekes


On Dec. 9, 2012, 9:19 p.m., Tilghman Lesher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2241/
> -----------------------------------------------------------
> 
> (Updated Dec. 9, 2012, 9:19 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> 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.
> 
> 
> Diffs
> -----
> 
>   /trunk/apps/app_queue.c 377511 
>   /trunk/include/asterisk/term.h 377511 
>   /trunk/main/asterisk.c 377511 
>   /trunk/main/data.c 377511 
>   /trunk/main/logger.c 377511 
>   /trunk/main/manager.c 377511 
>   /trunk/main/pbx.c 377511 
>   /trunk/main/term.c 377511 
> 
> Diff: https://reviewboard.asterisk.org/r/2241/diff
> 
> 
> Testing
> -------
> 
> The code works, however, I haven't extended the change to all parts of Asterisk, simply because I wanted to get other eyes on the code and agree on the method employed.
> 
> 
> Thanks,
> 
> Tilghman
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20121210/7c721821/attachment-0001.htm>


More information about the asterisk-dev mailing list