Revision b9c353ff
libavutil/log.c | ||
---|---|---|
32 | 32 |
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) |
33 | 33 |
{ |
34 | 34 |
static int print_prefix=1; |
35 |
static int count; |
|
36 |
static char line[1024], prev[1024]; |
|
35 | 37 |
AVClass* avc= ptr ? *(AVClass**)ptr : NULL; |
36 | 38 |
if(level>av_log_level) |
37 | 39 |
return; |
38 | 40 |
#undef fprintf |
39 | 41 |
if(print_prefix && avc) { |
40 |
fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), ptr); |
|
41 |
} |
|
42 |
snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr); |
|
43 |
}else |
|
44 |
line[0]=0; |
|
42 | 45 |
|
43 |
print_prefix= strstr(fmt, "\n") != NULL;
|
|
46 |
vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
|
|
44 | 47 |
|
45 |
vfprintf(stderr, fmt, vl); |
|
48 |
print_prefix= line[strlen(line)-1] == '\n'; |
|
49 |
if(print_prefix && !strcmp(line, prev)){ |
|
50 |
count++; |
|
51 |
return; |
|
52 |
} |
|
53 |
if(count>0){ |
|
54 |
fprintf(stderr, " Last message repeated %d times\n", count); |
|
55 |
count=0; |
|
56 |
} |
|
57 |
fputs(line, stderr); |
|
58 |
strcpy(prev, line); |
|
46 | 59 |
} |
47 | 60 |
|
48 | 61 |
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; |
Also available in: Unified diff