[FFmpeg-devel] [PATCH] log: color prefixes according to their source.

Clément Bœsch ubitux at gmail.com
Mon May 28 07:56:40 CEST 2012


On Mon, May 28, 2012 at 03:23:51AM +0200, Michael Niedermayer wrote:
> The use of cyan is droped from the levels to avoid confusion
> magenta/cyan/blue is used for muxer/codec/filter layer
> 

Ah it's nice!

Unfortunately it doesn't match filter with their own context (which
happens often). Maybe I'd avoid the mix of bold (light) and non-bold
colors for semantically similar elements: codec/cyan is normal style,
while muxer/blue is a "light blue" (see attached). It's not a problem with
the errors, but I think the categories should have a common style (and yes
I know the "normal" colors are not always readable, and available colors
limited).

> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavutil/log.c |   55 +++++++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 43 insertions(+), 12 deletions(-)
> 
> diff --git a/libavutil/log.c b/libavutil/log.c
> index e62f11c..2eae355 100644
> --- a/libavutil/log.c
> +++ b/libavutil/log.c
> @@ -34,13 +34,17 @@ static int flags;
>  
>  #if defined(_WIN32) && !defined(__MINGW32CE__)
>  #include <windows.h>
> -static const uint8_t color[] = { 12, 12, 12, 14, 7, 10, 11 };
> +static const uint8_t color[] = { 12, 12, 12, 14, 7, 10, 10,
> +                                  3, 11,  5, 13, 1,  9
> +};
>  static int16_t background, attr_orig;
>  static HANDLE con;
>  #define set_color(x)  SetConsoleTextAttribute(con, background | color[x])
>  #define reset_color() SetConsoleTextAttribute(con, attr_orig)
>  #else
> -static const uint8_t color[] = { 0x41, 0x41, 0x11, 0x03, 9, 0x02, 0x06 };
> +static const uint8_t color[] = { 0x41, 0x41, 0x11, 0x03, 9, 0x02, 0x02,
> +                                 0x06, 0x16, 0x05, 0x15, 0x04, 0x14
> +};
>  #define set_color(x)  fprintf(stderr, "\033[%d;3%dm", color[x] >> 4, color[x]&15)
>  #define reset_color() fprintf(stderr, "\033[0m")
>  #endif
> @@ -92,27 +96,47 @@ static void sanitize(uint8_t *line){
>      }
>  }
>  
> -void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
> -                        char *line, int line_size, int *print_prefix)
> +static int get_category(AVClass *avc){
> +    if(!avc) return 4;
> +    if(!strcmp(avc->class_name, "AVFormatContext")) return 7;
> +    if(!strcmp(avc->class_name, "AVIOContext") || !strcmp(avc->class_name, "URLOContext")) return 8;

I think you meant "URLContext" here.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bold-nonbold.png
Type: image/png
Size: 23749 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120528/3ececeb2/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120528/3ececeb2/attachment.asc>


More information about the ffmpeg-devel mailing list