mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Merge commit '7763118cae4eb468b032dbd29af15a011c2c233b'
* commit '7763118cae4eb468b032dbd29af15a011c2c233b': log: Support for 256color terminals Conflicts: doc/APIchanges libavutil/log.c libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
c16e006181
@ -15,6 +15,9 @@ libavutil: 2012-10-22
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
2014-04-xx - xxxxxxx - lavu 53.09.0 - log.h
|
||||
Add AV_LOG(c) macro to have 256 color debug messages.
|
||||
|
||||
2014-04-xx - xxxxxxx - lavu 52.72.100 - opt.h
|
||||
Add AV_OPT_MULTI_COMPONENT_RANGE define to allow return
|
||||
multi-component option ranges.
|
||||
|
@ -126,9 +126,11 @@ static void check_color_terminal(void)
|
||||
background = attr_orig & 0xF0;
|
||||
}
|
||||
#elif HAVE_ISATTY
|
||||
char *term = getenv("TERM");
|
||||
use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") &&
|
||||
(getenv("TERM") && isatty(2) || getenv("AV_LOG_FORCE_COLOR"));
|
||||
if (getenv("AV_LOG_FORCE_256COLOR"))
|
||||
if ( getenv("AV_LOG_FORCE_256COLOR")
|
||||
|| strstr(term, "256color"));
|
||||
use_color *= 256;
|
||||
#else
|
||||
use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") &&
|
||||
@ -136,7 +138,7 @@ static void check_color_terminal(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void colored_fputs(int level, const char *str)
|
||||
static void colored_fputs(int level, int tint, const char *str)
|
||||
{
|
||||
if (!*str)
|
||||
return;
|
||||
@ -157,6 +159,12 @@ static void colored_fputs(int level, const char *str)
|
||||
(color[level] >> 4) & 15,
|
||||
color[level] & 15,
|
||||
str);
|
||||
} else if (tint && use_color == 256) {
|
||||
fprintf(stderr,
|
||||
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
|
||||
(color[level] >> 16) & 0xff,
|
||||
tint,
|
||||
str);
|
||||
} else if (use_color == 256 && level != AV_LOG_INFO/8) {
|
||||
fprintf(stderr,
|
||||
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
|
||||
@ -250,6 +258,10 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
||||
char line[LINE_SZ];
|
||||
static int is_atty;
|
||||
int type[2];
|
||||
int tint = av_clip(level >> 8, 0, 256);
|
||||
|
||||
level &= 0xff;
|
||||
|
||||
|
||||
if (level > av_log_level)
|
||||
return;
|
||||
@ -278,11 +290,11 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
||||
}
|
||||
strcpy(prev, line);
|
||||
sanitize(part[0].str);
|
||||
colored_fputs(type[0], part[0].str);
|
||||
colored_fputs(type[0], 0, part[0].str);
|
||||
sanitize(part[1].str);
|
||||
colored_fputs(type[1], part[1].str);
|
||||
colored_fputs(type[1], 0, part[1].str);
|
||||
sanitize(part[2].str);
|
||||
colored_fputs(av_clip(level >> 3, 0, 6), part[2].str);
|
||||
colored_fputs(av_clip(level >> 3, 0, 6), tint, part[2].str);
|
||||
end:
|
||||
av_bprint_finalize(part+2, NULL);
|
||||
#if HAVE_PTHREADS
|
||||
|
@ -187,6 +187,14 @@ typedef struct AVClass {
|
||||
|
||||
#define AV_LOG_MAX_OFFSET (AV_LOG_DEBUG - AV_LOG_QUIET)
|
||||
|
||||
/**
|
||||
* Sets additional colors for extended debugging sessions.
|
||||
* Requires 256color terminal support. Use outside debugging is not
|
||||
* recommended.
|
||||
*/
|
||||
|
||||
#define AV_LOG_C(x) (x << 8)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 52
|
||||
#define LIBAVUTIL_VERSION_MINOR 72
|
||||
#define LIBAVUTIL_VERSION_MINOR 73
|
||||
#define LIBAVUTIL_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user