Browse Source

libvlc: helper to log to a FILE

pull/2/head
Rémi Denis-Courmont 15 years ago
parent
commit
d4dd87619e
  1. 13
      include/vlc/libvlc.h
  2. 19
      lib/log.c

13
include/vlc/libvlc.h

@ -56,11 +56,13 @@
# define LIBVLC_DEPRECATED
#endif
#include <stdio.h>
#include <stdarg.h>
# ifdef __cplusplus
extern "C" {
# endif
#include <stdarg.h>
#include <vlc/libvlc_structures.h>
/** \defgroup libvlc_core LibVLC core
@ -370,6 +372,15 @@ typedef struct libvlc_log_subscriber
LIBVLC_API void libvlc_log_subscribe( libvlc_log_subscriber_t *sub,
libvlc_log_cb cb, void *data );
/**
* Registers a logging callback to a file.
* @param stream FILE pointer opened for writing
* (the FILE pointer must remain valid until libvlc_log_unsubscribe())
*/
LIBVLC_API void libvlc_log_subscribe_file( libvlc_log_subscriber_t *sub,
FILE *stream );
/**
* Deregisters a logging callback from LibVLC.
* This function is thread-safe.

19
lib/log.c

@ -113,6 +113,25 @@ void libvlc_log_unsubscribe( libvlc_log_subscriber_t *sub )
vlc_rwlock_unlock (&log_lock);
}
/*** Helpers for logging to files ***/
static void libvlc_log_file (void *data, int level, const char *fmt,
va_list ap)
{
FILE *stream = data;
flockfile (stream);
vfprintf (stream, fmt, ap);
fputc ('\n', stream);
funlockfile (stream);
(void) level;
}
void libvlc_log_subscribe_file (libvlc_log_subscriber_t *sub, FILE *stream)
{
libvlc_log_subscribe (sub, libvlc_log_file, stream);
}
/*** Stubs for the old interface ***/
unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance )
{
(void) p_instance;

Loading…
Cancel
Save