3 * \brief logging functions
5 * Copyright (c) 2003 Michel Bardiaux
7 * This file was a part of FFmpeg.
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "mlt_service.h"
29 static int log_level = MLT_LOG_INFO;
31 void default_callback( void* ptr, int level, const char* fmt, va_list vl )
33 static int print_prefix = 1;
34 mlt_properties properties = ptr ? MLT_SERVICE_PROPERTIES( ( mlt_service )ptr ) : NULL;
36 if ( level > log_level )
38 if ( print_prefix && properties )
40 char *mlt_type = mlt_properties_get( properties, "mlt_type" );
41 char *resource = mlt_properties_get( properties, "resource" );
43 if ( resource && *resource && resource[0] == '<' && resource[ strlen(resource) - 1 ] == '>' )
45 fprintf( stderr, "[%s @ %p]", mlt_type, ptr );
47 print_prefix = strstr( fmt, "\n" ) != NULL;
48 vfprintf( stderr, fmt, vl );
51 static void ( *callback )( void*, int, const char*, va_list ) = default_callback;
53 void mlt_log( void* service, int level, const char *fmt, ...)
58 mlt_vlog( service, level, fmt, vl );
62 void mlt_vlog( void* service, int level, const char *fmt, va_list vl )
64 if ( callback ) callback( service, level, fmt, vl );
67 int mlt_log_get_level( void )
72 void mlt_log_set_level( int level )
77 void mlt_log_set_callback( void (*new_callback)( void*, int, const char*, va_list ) )
79 callback = new_callback;