direct3d11: map all planes at once
[vlc.git] / lib / log.c
blobf3a769a9ba21ee635c172afbeb8fe51074975c4a
1 /*****************************************************************************
2 * log.c: libvlc new API log functions
3 *****************************************************************************
4 * Copyright (C) 2005 VLC authors and VideoLAN
6 * $Id$
8 * Authors: Damien Fouilleul <damienf@videolan.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
29 #include <assert.h>
30 #include <vlc/vlc.h>
31 #include "libvlc_internal.h"
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
35 /*** Logging core dispatcher ***/
37 void libvlc_log_get_context(const libvlc_log_t *ctx,
38 const char **restrict module,
39 const char **restrict file,
40 unsigned *restrict line)
42 if (module != NULL)
43 *module = ctx->psz_module;
44 if (file != NULL)
45 *file = ctx->file;
46 if (line != NULL)
47 *line = ctx->line;
50 void libvlc_log_get_object(const libvlc_log_t *ctx,
51 const char **restrict name,
52 const char **restrict header,
53 uintptr_t *restrict id)
55 if (name != NULL)
56 *name = (ctx->psz_object_type != NULL)
57 ? ctx->psz_object_type : "generic";
58 if (header != NULL)
59 *header = ctx->psz_header;
60 if (id != NULL)
61 *id = ctx->i_object_id;
64 static void libvlc_logf (void *data, int level, const vlc_log_t *item,
65 const char *fmt, va_list ap)
67 libvlc_instance_t *inst = data;
69 switch (level)
71 case VLC_MSG_INFO: level = LIBVLC_NOTICE; break;
72 case VLC_MSG_ERR: level = LIBVLC_ERROR; break;
73 case VLC_MSG_WARN: level = LIBVLC_WARNING; break;
74 case VLC_MSG_DBG: level = LIBVLC_DEBUG; break;
77 inst->log.cb (inst->log.data, level, item, fmt, ap);
80 void libvlc_log_unset (libvlc_instance_t *inst)
82 vlc_LogSet (inst->p_libvlc_int, NULL, NULL);
85 void libvlc_log_set (libvlc_instance_t *inst, libvlc_log_cb cb, void *data)
87 libvlc_log_unset (inst); /* <- Barrier before modifying the callback */
88 inst->log.cb = cb;
89 inst->log.data = data;
90 vlc_LogSet (inst->p_libvlc_int, libvlc_logf, inst);
93 /*** Helpers for logging to files ***/
94 static void libvlc_log_file (void *data, int level, const libvlc_log_t *log,
95 const char *fmt, va_list ap)
97 FILE *stream = data;
99 flockfile (stream);
100 vfprintf (stream, fmt, ap);
101 fputc ('\n', stream);
102 funlockfile (stream);
103 (void) level; (void) log;
106 void libvlc_log_set_file (libvlc_instance_t *inst, FILE *stream)
108 libvlc_log_set (inst, libvlc_log_file, stream);
111 /*** Stubs for the old interface ***/
112 unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance )
114 (void) p_instance;
115 return -1;
118 void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level )
120 (void) p_instance;
121 (void) level;
124 libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance )
126 (void) p_instance;
127 return malloc(sizeof(libvlc_log_t));
130 void libvlc_log_close( libvlc_log_t *p_log )
132 free(p_log);
135 unsigned libvlc_log_count( const libvlc_log_t *p_log )
137 (void) p_log;
138 return 0;
141 void libvlc_log_clear( libvlc_log_t *p_log )
143 (void) p_log;
146 libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log )
148 return (p_log != NULL) ? malloc(1) : NULL;
151 void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter )
153 free( p_iter );
156 int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter )
158 (void) p_iter;
159 return 0;
162 libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
163 libvlc_log_message_t *buffer )
165 (void) p_iter; (void) buffer;
166 return NULL;