# HG changeset patch # User michael # Date 1235325194 0 # Node ID 4cd8f715ab172e07227a611ece5fc352764e4e21 # Parent e847c4a1d29ae9045b2cad71d83bd7cc740a38ce Compact repeated messages to "Last message repeated x times". diff -r e847c4a1d29a -r 4cd8f715ab17 log.c --- a/log.c Sun Feb 22 14:27:50 2009 +0000 +++ b/log.c Sun Feb 22 17:53:14 2009 +0000 @@ -32,17 +32,30 @@ 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; + + vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); - print_prefix= strstr(fmt, "\n") != NULL; - - 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;