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_WARNING;
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 *mlt_service = mlt_properties_get( properties, "mlt_service" );
42 char *resource = mlt_properties_get( properties, "resource" );
44 if ( !( resource && *resource && resource[0] == '<' && resource[ strlen(resource) - 1 ] == '>' ) )
45 mlt_type = mlt_properties_get( properties, "mlt_type" );
47 fprintf( stderr, "[%s %s] ", mlt_type, mlt_service );
49 fprintf( stderr, "[%s %p] ", mlt_type, ptr );
51 fprintf( stderr, "%s\n ", resource );
53 print_prefix = strstr( fmt, "\n" ) != NULL;
54 vfprintf( stderr, fmt, vl );
57 static void ( *callback )( void*, int, const char*, va_list ) = default_callback;
59 void mlt_log( void* service, int level, const char *fmt, ...)
64 mlt_vlog( service, level, fmt, vl );
68 void mlt_vlog( void* service, int level, const char *fmt, va_list vl )
70 if ( callback ) callback( service, level, fmt, vl );
73 int mlt_log_get_level( void )
78 void mlt_log_set_level( int level )
83 void mlt_log_set_callback( void (*new_callback)( void*, int, const char*, va_list ) )
85 callback = new_callback;