Commit 11498d06 authored by ramiro's avatar ramiro

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.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@23553 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 2e027796
...@@ -34,10 +34,11 @@ static ...@@ -34,10 +34,11 @@ static
#endif #endif
int av_log_level = AV_LOG_INFO; int av_log_level = AV_LOG_INFO;
static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9};
static int use_color=-1; static int use_color=-1;
#undef fprintf #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(use_color<0){
#if HAVE_ISATTY && !defined(_WIN32) #if HAVE_ISATTY && !defined(_WIN32)
use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2); use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2);
...@@ -47,7 +48,7 @@ static void colored_fputs(int color, const char *str){ ...@@ -47,7 +48,7 @@ static void colored_fputs(int color, const char *str){
} }
if(use_color){ 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); fputs(str, stderr);
if(use_color){ if(use_color){
...@@ -64,7 +65,6 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) ...@@ -64,7 +65,6 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
static int print_prefix=1; static int print_prefix=1;
static int count; static int count;
static char line[1024], prev[1024]; static char line[1024], prev[1024];
static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9};
AVClass* avc= ptr ? *(AVClass**)ptr : NULL; AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
if(level>av_log_level) if(level>av_log_level)
return; return;
...@@ -91,7 +91,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) ...@@ -91,7 +91,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
fprintf(stderr, " Last message repeated %d times\n", count); fprintf(stderr, " Last message repeated %d times\n", count);
count=0; count=0;
} }
colored_fputs(color[av_clip(level>>3, 0, 6)], line); colored_fputs(av_clip(level>>3, 0, 6), line);
strcpy(prev, line); strcpy(prev, line);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment