fix arm asm compilation in mpegaudiodec
[libav.git] / libavutil / log.c
1 /*
2 * log functions
3 * Copyright (c) 2003 Michel Bardiaux
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /**
21 * @file log.c
22 * log.
23 */
24
25 #include "avutil.h"
26
27 int av_log_level = AV_LOG_INFO;
28
29 static void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
30 {
31 static int print_prefix=1;
32 AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
33 if(level>av_log_level)
34 return;
35 #undef fprintf
36 if(print_prefix && avc) {
37 fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), avc);
38 }
39 #define fprintf please_use_av_log
40
41 print_prefix= strstr(fmt, "\n") != NULL;
42
43 vfprintf(stderr, fmt, vl);
44 }
45
46 #if LIBAVUTIL_VERSION_INT < (50<<16)
47 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
48 #else
49 void (*av_vlog)(void*, int, const char*, va_list) = av_log_default_callback;
50 #endif
51
52 void av_log(void* avcl, int level, const char *fmt, ...)
53 {
54 va_list vl;
55 va_start(vl, fmt);
56 av_vlog(avcl, level, fmt, vl);
57 va_end(vl);
58 }
59
60 #if LIBAVUTIL_VERSION_INT < (50<<16)
61 void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
62 {
63 av_log_callback(avcl, level, fmt, vl);
64 }
65
66 int av_log_get_level(void)
67 {
68 return av_log_level;
69 }
70
71 void av_log_set_level(int level)
72 {
73 av_log_level = level;
74 }
75
76 void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
77 {
78 av_log_callback = callback;
79 }
80 #endif