[libav-devel] [PATCH] log: introduce HINT level

Vittorio Giovara vittorio.giovara at gmail.com
Tue Nov 26 15:33:48 CET 2013


---
It might be useful to have an additional log level to notify users of correct behavious instead of leaving them in the dark. I tried adding it without breaking
ABI or deprecation warnings. Also added an example that will be split in a separate patch when after a decision is taken.

I picked the color of light (bold) green, works in unix terminals, but can anyone double check on windows?

Thoughts, ideas?
Vittorio

 avconv_filter.c |    2 +-
 libavutil/log.c |    6 +++---
 libavutil/log.h |    4 ++++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/avconv_filter.c b/avconv_filter.c
index 262b4ee..7c7c485 100644
--- a/avconv_filter.c
+++ b/avconv_filter.c
@@ -611,7 +611,7 @@ int configure_filtergraph(FilterGraph *fg)
     if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
         av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have "
                "exactly one input and output.\n", graph_desc);
-        av_log(NULL, AV_LOG_WARNING, "Maybe use -filter_complex instead of -vf?\n", graph_desc);
+        av_log(NULL, AV_LOG_HINT, "Maybe use -filter_complex instead of -vf?\n", graph_desc);
         return AVERROR(EINVAL);
     }
 
diff --git a/libavutil/log.c b/libavutil/log.c
index 7d574f6..af4bfcb 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -45,13 +45,13 @@ static int flags;
 
 #if HAVE_SETCONSOLETEXTATTRIBUTE
 #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, 2, 11 };
 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, 0x09, 0x02, 0x13, 0x06};
 #define set_color(x)  fprintf(stderr, "\033[%d;3%dm", color[x] >> 4, color[x]&15)
 #define reset_color() fprintf(stderr, "\033[0m")
 #endif
@@ -102,7 +102,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
     char line[1024];
     static int is_atty;
     AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
-    if (level > av_log_level)
+    if (level > av_log_level && level != AV_LOG_HINT)
         return;
     line[0] = 0;
     if (print_prefix && avc) {
diff --git a/libavutil/log.h b/libavutil/log.h
index 05d2826..9a617db 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -144,6 +144,10 @@ typedef struct AVClass {
 #define AV_LOG_DEBUG    48
 
 /**
+ * Possible help text.
+ */
+#define AV_LOG_HINT     56
+/**
  * @}
  */
 
-- 
1.7.9.5



More information about the libav-devel mailing list