changeset 935:096294624d52 libavutil

Move ansi color array to outside of av_log_default_callback(). Do not pass ansi color code to colored_fputs(), and pass instead the error level so the proper color code may be used.
author ramiro
date Wed, 09 Jun 2010 18:10:35 +0000
parents 252d7a7ee7d5
children 41b43a526d0d
files log.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/log.c	Wed Jun 09 18:07:44 2010 +0000
+++ b/log.c	Wed Jun 09 18:10:35 2010 +0000
@@ -34,10 +34,11 @@
 #endif
 int av_log_level = AV_LOG_INFO;
 
+static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9};
 static int use_color=-1;
 
 #undef fprintf
-static void colored_fputs(int color, const char *str){
+static void colored_fputs(int level, const char *str){
     if(use_color<0){
 #if HAVE_ISATTY && !defined(_WIN32)
         use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2);
@@ -47,7 +48,7 @@
     }
 
     if(use_color){
-        fprintf(stderr, "\033[%d;3%dm", color>>4, color&15);
+        fprintf(stderr, "\033[%d;3%dm", color[level]>>4, color[level]&15);
     }
     fputs(str, stderr);
     if(use_color){
@@ -64,7 +65,6 @@
     static int print_prefix=1;
     static int count;
     static char line[1024], prev[1024];
-    static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9};
     AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
     if(level>av_log_level)
         return;
@@ -91,7 +91,7 @@
         fprintf(stderr, "    Last message repeated %d times\n", count);
         count=0;
     }
-    colored_fputs(color[av_clip(level>>3, 0, 6)], line);
+    colored_fputs(av_clip(level>>3, 0, 6), line);
     strcpy(prev, line);
 }