00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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), avc);
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 }