MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_log_default_callback

Function av_log_default_callback

libavutil/log.c:380–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
381{
382 static int print_prefix = 1;
383 static int count;
384 static char prev[LINE_SZ];
385 AVBPrint part[5];
386 char line[LINE_SZ];
387 static int is_atty;
388 int type[2];
389 unsigned tint = 0;
390
391 if (level >= 0) {
392 tint = level & 0xff00;
393 level &= 0xff;
394 }
395
396 if (level > atomic_load_explicit(&av_log_level, memory_order_relaxed))
397 return;
398 ff_mutex_lock(&mutex);
399
400 format_line(ptr, level, fmt, vl, part, &print_prefix, type);
401 snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
402
403#if HAVE_ISATTY
404 if (!is_atty)
405 is_atty = isatty(2) ? 1 : -1;
406#endif
407
408 if (print_prefix && (atomic_load_explicit(&av_log_flags, memory_order_relaxed) & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
409 *line && line[strlen(line) - 1] != '\r'){
410 count++;
411 if (is_atty == 1)
412 fprintf(stderr, " Last message repeated %d times\r", count);
413 goto end;
414 }
415 if (count > 0) {
416 fprintf(stderr, " Last message repeated %d times\n", count);
417 count = 0;
418 }
419 strcpy(prev, line);
420
421 sanitize(part[4].str);
422 colored_fputs(7, 0, part[4].str);
423 sanitize(part[0].str);
424 colored_fputs(type[0], 0, part[0].str);
425 sanitize(part[1].str);
426 colored_fputs(type[1], 0, part[1].str);
427 sanitize(part[2].str);
428 colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[2].str);
429 sanitize(part[3].str);
430 colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[3].str);
431
432#if CONFIG_VALGRIND_BACKTRACE
433 if (level <= BACKTRACE_LOGLEVEL)
434 VALGRIND_PRINTF_BACKTRACE("%s", "");
435#endif
436end:
437 av_bprint_finalize(part+3, NULL);

Callers 3

log_callback_reportFunction · 0.85
log_callbackFunction · 0.85
log_stdoutFunction · 0.85

Calls 6

ff_mutex_lockFunction · 0.85
format_lineFunction · 0.85
sanitizeFunction · 0.85
colored_fputsFunction · 0.85
av_bprint_finalizeFunction · 0.85
ff_mutex_unlockFunction · 0.85

Tested by 1

log_stdoutFunction · 0.68