Compact repeated messages to "Last message repeated x times".
Originally committed as revision 17531 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
adc5abf781
commit
b9c353fff2
@ -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)
|
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
||||||
{
|
{
|
||||||
static int print_prefix=1;
|
static int print_prefix=1;
|
||||||
|
static int count;
|
||||||
|
static char line[1024], prev[1024];
|
||||||
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
|
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
|
||||||
if(level>av_log_level)
|
if(level>av_log_level)
|
||||||
return;
|
return;
|
||||||
#undef fprintf
|
#undef fprintf
|
||||||
if(print_prefix && avc) {
|
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= line[strlen(line)-1] == '\n';
|
||||||
|
if(print_prefix && !strcmp(line, prev)){
|
||||||
|
count++;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if(count>0){
|
||||||
print_prefix= strstr(fmt, "\n") != NULL;
|
fprintf(stderr, " Last message repeated %d times\n", count);
|
||||||
|
count=0;
|
||||||
vfprintf(stderr, fmt, vl);
|
}
|
||||||
|
fputs(line, stderr);
|
||||||
|
strcpy(prev, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
|
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user