summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/APIchanges3
-rw-r--r--libavutil/log.c22
-rw-r--r--libavutil/log.h8
-rw-r--r--libavutil/version.h2
4 files changed, 29 insertions, 6 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 475db5d951..237d39e442 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -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.
diff --git a/libavutil/log.c b/libavutil/log.c
index af293e724b..b39196d5ff 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -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
diff --git a/libavutil/log.h b/libavutil/log.h
index f16e38221b..48abd4a1b9 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -188,6 +188,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)
+
+/**
* @}
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index 9bf499416e..38f9bce6f7 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -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, \