]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Compact repeated messages to "Last message repeated x times".
authormichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 22 Feb 2009 17:53:14 +0000 (17:53 +0000)
committermichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 22 Feb 2009 17:53:14 +0000 (17:53 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17531 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavutil/log.c

index 65328bb25f6417d37b23b32fbeef3f98eba9f1e0..4bb9652c2c71e22dfb072377905f78eeaf1b189a 100644 (file)
@@ -32,17 +32,30 @@ int av_log_level = AV_LOG_INFO;
 void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
 {
     static int print_prefix=1;
+    static int count;
+    static char line[1024], prev[1024];
     AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
     if(level>av_log_level)
         return;
 #undef fprintf
     if(print_prefix && avc) {
-        fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), ptr);
-    }
+        snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr);
+    }else
+        line[0]=0;
 
-    print_prefix= strstr(fmt, "\n") != NULL;
+    vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
 
-    vfprintf(stderr, fmt, vl);
+    print_prefix= line[strlen(line)-1] == '\n';
+    if(print_prefix && !strcmp(line, prev)){
+        count++;
+        return;
+    }
+    if(count>0){
+        fprintf(stderr, "    Last message repeated %d times\n", count);
+        count=0;
+    }
+    fputs(line, stderr);
+    strcpy(prev, line);
 }
 
 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;