Example #1
0
static void plex_log_callback(void* ptr, int level, const char* fmt, va_list vl)
{
    int print_prefix = 1;
    char line[1024];
    va_list vl2;

#if HAVE_PTHREADS
    char *cur_line;
    pthread_once(&key_once, make_keys);
#else
    static __thread char cur_line[LOG_LINE_SIZE] = {0};
    static __thread int logging = 0;
#endif

    va_copy(vl2, vl);
    av_log_default_callback(ptr, level, fmt, vl2);

    if (level > av_log_level_plex)
        return;

    //Avoid recusive logging
#if HAVE_PTHREADS
    if (pthread_getspecific(logging_key))
        return;
    cur_line = pthread_getspecific(cur_line_key);
    if (!cur_line) {
        cur_line = av_mallocz(LOG_LINE_SIZE);
        if (!cur_line)
            return;
        pthread_setspecific(cur_line_key, cur_line);
    }
    pthread_setspecific(logging_key, (void*)1);
#else
    if (logging)
        return;
    logging = 1;
#endif

    av_log_format_line(ptr, level, fmt, vl, line, sizeof(line), &print_prefix);
    av_strlcat(cur_line, line, LOG_LINE_SIZE);
    if (print_prefix) {
        int len = strlen(cur_line);
        if (len) {
            cur_line[len - 1] = 0;
            PMS_Log(level < AV_LOG_ERROR ? LOG_LEVEL_ERROR : (level / 8) - 2, "%s", cur_line);
            cur_line[0] = 0;
        }
    }

#if HAVE_PTHREADS
    pthread_setspecific(logging_key, NULL);
#else
    logging = 0;
#endif
}
Example #2
0
static void av_qsv_log_callback(void *ptr, int level, const char *fmt, va_list vl) {
    if (auto pQSVLog = g_pQSVLog.lock()) {
        const int qsv_log_level = log_level_av2rgy(level);
        if (qsv_log_level >= pQSVLog->getLogLevel() && pQSVLog->logFileAvail()) {
            char mes[4096];
            av_log_format_line(ptr, level, fmt, vl, mes, sizeof(mes), &print_prefix);
            pQSVLog->write_log(qsv_log_level, char_to_tstring(mes, CP_UTF8).c_str(), true);
        }
    }
    av_log_default_callback(ptr, level, fmt, vl);
}
Example #3
0
static void avQMPlay2LogHandler(void *avcl, int level, const char *fmt, va_list vl)
{
	if (level <= AV_LOG_FATAL)
	{
		const QByteArray msg = QString::vasprintf(fmt, vl).trimmed().toUtf8();
		qCCritical(ffmpeglog) << msg.constData();
	}
	else
	{
		av_log_default_callback(avcl, level, fmt, vl);
	}
}
Example #4
0
static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
{
    va_list vl2;
    char line[1024];
    static int print_prefix = 1;

    va_copy(vl2, vl);
    av_log_default_callback(ptr, level, fmt, vl);
    av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
    va_end(vl2);
    fputs(line, report_file);
    fflush(report_file);
}
Example #5
0
static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg)
{
	if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
		size_t n;
		va_list args_cpy;

		va_copy(args_cpy, arg);
		n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, args_cpy);
		va_end(args_cpy);

		/* strip trailing \n */
		ffmpeg_last_error[n - 1] = '\0';
	}

	if (G.debug & G_DEBUG_FFMPEG) {
		/* call default logger to print all message to console */
		av_log_default_callback(ptr, level, format, arg);
	}
}