log.c

Go to the documentation of this file.
00001 /*
00002  * log functions
00003  * Copyright (c) 2003 Michel Bardiaux
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 /**
00023  * @file log.c
00024  * log.
00025  */
00026 
00027 #include "avutil.h"
00028 
00029 int av_log_level = AV_LOG_INFO;
00030 
00031 void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
00032 {
00033     static int print_prefix=1;
00034     AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
00035     if(level>av_log_level)
00036         return;
00037 #undef fprintf
00038     if(print_prefix && avc) {
00039             fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), ptr);
00040     }
00041 #define fprintf please_use_av_log
00042 
00043     print_prefix= strstr(fmt, "\n") != NULL;
00044 
00045     vfprintf(stderr, fmt, vl);
00046 }
00047 
00048 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
00049 
00050 void av_log(void* avcl, int level, const char *fmt, ...)
00051 {
00052     va_list vl;
00053     va_start(vl, fmt);
00054     av_vlog(avcl, level, fmt, vl);
00055     va_end(vl);
00056 }
00057 
00058 void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
00059 {
00060     av_log_callback(avcl, level, fmt, vl);
00061 }
00062 
00063 int av_log_get_level(void)
00064 {
00065     return av_log_level;
00066 }
00067 
00068 void av_log_set_level(int level)
00069 {
00070     av_log_level = level;
00071 }
00072 
00073 void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
00074 {
00075     av_log_callback = callback;
00076 }

Generated on Thu Nov 20 05:44:45 2008 for libextractor by  doxygen 1.5.1