VLC  3.0.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Typedefs | Enumerations | Functions
LibVLC logging

libvlc_log_* functions provide access to the LibVLC messages log. More...

Collaboration diagram for LibVLC logging:

Typedefs

typedef struct vlc_log_t libvlc_log_t
 
typedef void(* libvlc_log_cb )(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_list args)
 Callback prototype for LibVLC log message handler. More...
 

Enumerations

enum  libvlc_log_level { LIBVLC_DEBUG =0, LIBVLC_NOTICE =2, LIBVLC_WARNING =3, LIBVLC_ERROR =4 }
 Logging messages level. More...
 

Functions

void libvlc_log_get_context (const libvlc_log_t *ctx, const char **module, const char **file, unsigned *line)
 Gets log message debug infos. More...
 
void libvlc_log_get_object (const libvlc_log_t *ctx, const char **name, const char **header, uintptr_t *id)
 Gets log message info. More...
 
void libvlc_log_unset (libvlc_instance_t *)
 Unsets the logging callback. More...
 
void libvlc_log_set (libvlc_instance_t *, libvlc_log_cb cb, void *data)
 Sets the logging callback for a LibVLC instance. More...
 
void libvlc_log_set_file (libvlc_instance_t *, FILE *stream)
 Sets up logging to a file. More...
 

Detailed Description

libvlc_log_* functions provide access to the LibVLC messages log.

This is used for logging and debugging.

Typedef Documentation

typedef void(* libvlc_log_cb)(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_list args)

Callback prototype for LibVLC log message handler.

Parameters
datadata pointer as given to libvlc_log_set()
levelmessage level (libvlc_log_level)
ctxmessage context (meta-information about the message)
fmtprintf() format string (as defined by ISO C11)
argsvariable argument list for the format
Note
Log message handlers must be thread-safe.
Warning
The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns.
typedef struct vlc_log_t libvlc_log_t

Enumeration Type Documentation

Logging messages level.

Note
Future LibVLC versions may define new levels.
Enumerator
LIBVLC_DEBUG 

Debug message.

LIBVLC_NOTICE 

Important informational message.

LIBVLC_WARNING 

Warning (potential error) message.

LIBVLC_ERROR 

Error message.

Function Documentation

void libvlc_log_get_context ( const libvlc_log_t ctx,
const char **  module,
const char **  file,
unsigned *  line 
)

Gets log message debug infos.

This function retrieves self-debug information about a log message:

  • the name of the VLC module emitting the message,
  • the name of the source code module (i.e. file) and
  • the line number within the source code module.

The returned module name and file name will be NULL if unknown. The returned line number will similarly be zero if unknown.

Parameters
ctxmessage context (as passed to the libvlc_log_cb callback)
modulemodule name storage (or NULL) [OUT]
filesource code file name storage (or NULL) [OUT]
linesource code file line number storage (or NULL) [OUT]
Warning
The returned module name and source code file name, if non-NULL, are only valid until the logging callback returns.
Version
LibVLC 2.1.0 or later
void libvlc_log_get_object ( const libvlc_log_t ctx,
const char **  name,
const char **  header,
uintptr_t *  id 
)

Gets log message info.

This function retrieves meta-information about a log message:

  • the type name of the VLC object emitting the message,
  • the object header if any, and
  • a temporaly-unique object identifier.

This information is mainly meant for manual troubleshooting.

The returned type name may be "generic" if unknown, but it cannot be NULL. The returned header will be NULL if unset; in current versions, the header is used to distinguish for VLM inputs. The returned object ID will be zero if the message is not associated with any VLC object.

Parameters
ctxmessage context (as passed to the libvlc_log_cb callback)
nameobject name storage (or NULL) [OUT]
headerobject header (or NULL) [OUT]
linesource code file line number storage (or NULL) [OUT]
Warning
The returned module name and source code file name, if non-NULL, are only valid until the logging callback returns.
Version
LibVLC 2.1.0 or later
void libvlc_log_set ( libvlc_instance_t ,
libvlc_log_cb  cb,
void *  data 
)

Sets the logging callback for a LibVLC instance.

This function is thread-safe: it will wait for any pending callbacks invocation to complete.

Parameters
cbcallback function pointer
dataopaque data pointer for the callback function
Note
Some log messages (especially debug) are emitted by LibVLC while is being initialized. These messages cannot be captured with this interface.
Warning
A deadlock may occur if this function is called from the callback.
Parameters
p_instancelibvlc instance
Version
LibVLC 2.1.0 or later
void libvlc_log_set_file ( libvlc_instance_t ,
FILE *  stream 
)

Sets up logging to a file.

Parameters
p_instancelibvlc instance
streamFILE pointer opened for writing (the FILE pointer must remain valid until libvlc_log_unset())
Version
LibVLC 2.1.0 or later
void libvlc_log_unset ( libvlc_instance_t )

Unsets the logging callback.

This function deregisters the logging callback for a LibVLC instance. This is rarely needed as the callback is implicitly unset when the instance is destroyed.

Note
This function will wait for any pending callbacks invocation to complete (causing a deadlock if called from within the callback).
Parameters
p_instancelibvlc instance
Version
LibVLC 2.1.0 or later