[FFmpeg-devel] [PATCH 4/5] libavutil: helper function for forced log message at lowest possible priority

Martin Carroll martin.carroll at alcatel-lucent.com
Mon Jul 2 21:24:29 CEST 2012


The new function av_flog() forces the log message to come out, regardless of
the current log-level setting.  The log message is printed at the lowest
priority that is currently allowed to print.  To enable this feature, the
variable do_flog in libavutil/log.c must be set to 1.

Signed-off-by: Martin Carroll <martin.carroll at alcatel-lucent.com>
---
 libavutil/log.c |   11 +++++++++++
 libavutil/log.h |    4 ++++
 2 files changed, 15 insertions(+)

diff --git a/libavutil/log.c b/libavutil/log.c
index 74c915a..59b2437 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -53,6 +53,7 @@ static int num_thread_infos = 0;
 static int av_log_level = AV_LOG_INFO;
 static int flags;
 
+static int do_flog = 0; // set to 1 to enable calls to av_flog()
 static int do_pushpop = 0; // set to 1 to enable calls to LOGPUSH, LOGPOP, and LOGHERE
 static int print_threadid = 0; // set to 1 to prefix all log messages with name or id of thread
 
@@ -376,6 +377,16 @@ void av_log(void* avcl, int level, const char *fmt, ...)
     va_end(vl);
 }
 
+void av_flog(const char *fmt, ...)
+{
+    if (do_flog) {
+    	va_list vl;
+    	va_start(vl, fmt);
+    	av_vlog(NULL, av_log_level, fmt, vl);
+    	va_end(vl);
+    }
+}
+
 void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
 {
     if(av_log_callback)
diff --git a/libavutil/log.h b/libavutil/log.h
index 7f67459..006bb52 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -167,6 +167,10 @@ typedef struct AVClass {
  * @see av_vlog
  */
 void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
+
+// forces the log message to come out, regardless of the current log-level setting
+void av_flog(const char *fmt, ...) av_printf_format(1, 2);
+
 void av_log_set_threadname(pthread_t pid, const char* name, void *fcn);
 void av_log_push(const char *file, int line, const char *fcn);
 void av_log_pop(const char *file, int line, const char *fcn);
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list