Commit dac9ab98 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

libvlc: add functions to query log message "item" data

Also make provisions for file name and line number in the future.
parent cc71c7c6
...@@ -338,6 +338,49 @@ enum libvlc_log_level ...@@ -338,6 +338,49 @@ enum libvlc_log_level
typedef struct vlc_log_t libvlc_log_t; typedef struct vlc_log_t libvlc_log_t;
/**
* Gets debugging informations about a log message: the name of the VLC module
* emitting the message and the message location within the source code.
*
* The returned module name and file name will be NULL if unknown.
* The returned line number will similarly be zero if unknown.
*
* \param ctx message context (as passed to the @ref libvlc_log_cb callback)
* \param module module name storage (or NULL) [OUT]
* \param file source code file name storage (or NULL) [OUT]
* \param line source 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_context(const libvlc_log_t *ctx, const char **module,
const char **file, unsigned *restrict line);
/**
* Gets VLC object informations 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. These informations are mainly meant for <b>manual</b>
* 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.
*
* \param ctx message context (as passed to the @ref libvlc_log_cb callback)
* \param name object name storage (or NULL) [OUT]
* \param header object header (or NULL) [OUT]
* \param line source 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);
/** /**
* Callback prototype for LibVLC log message handler. * Callback prototype for LibVLC log message handler.
* \param data data pointer as given to libvlc_log_set() * \param data data pointer as given to libvlc_log_set()
...@@ -346,6 +389,8 @@ typedef struct vlc_log_t libvlc_log_t; ...@@ -346,6 +389,8 @@ typedef struct vlc_log_t libvlc_log_t;
* \param fmt printf() format string (as defined by ISO C11) * \param fmt printf() format string (as defined by ISO C11)
* \param args variable argument list for the format * \param args variable argument list for the format
* \note Log message handlers <b>must</b> be thread-safe. * \note Log message handlers <b>must</b> be thread-safe.
* \warning The message context pointer, the format string parameters and the
* variable arguments are only valid until the callback returns.
*/ */
typedef void (*libvlc_log_cb)(void *data, int level, const libvlc_log_t *ctx, typedef void (*libvlc_log_cb)(void *data, int level, const libvlc_log_t *ctx,
const char *fmt, va_list args); const char *fmt, va_list args);
......
...@@ -45,6 +45,8 @@ libvlc_get_fullscreen ...@@ -45,6 +45,8 @@ libvlc_get_fullscreen
libvlc_get_input_thread libvlc_get_input_thread
libvlc_get_log_verbosity libvlc_get_log_verbosity
libvlc_get_version libvlc_get_version
libvlc_log_get_context
libvlc_log_get_object
libvlc_log_set libvlc_log_set
libvlc_log_set_file libvlc_log_set_file
libvlc_log_unset libvlc_log_unset
......
...@@ -34,6 +34,33 @@ ...@@ -34,6 +34,33 @@
/*** Logging core dispatcher ***/ /*** Logging core dispatcher ***/
void libvlc_log_get_context(const libvlc_log_t *ctx,
const char **restrict module,
const char **restrict file,
unsigned *restrict line)
{
if (module != NULL)
*module = ctx->psz_module;
if (file != NULL)
*file = NULL;
if (line != NULL)
*line = 0;
}
void libvlc_log_get_object(const libvlc_log_t *ctx,
const char **restrict name,
const char **restrict header,
uintptr_t *restrict id)
{
if (name != NULL)
*name = (ctx->psz_object_type != NULL)
? ctx->psz_object_type : "generic";
if (header != NULL)
*header = ctx->psz_header;
if (id != NULL)
*id = ctx->i_object_id;
}
VLC_FORMAT(4,5) VLC_FORMAT(4,5)
static void libvlc_log (libvlc_instance_t *inst, int level, static void libvlc_log (libvlc_instance_t *inst, int level,
const libvlc_log_t *ctx, const char *fmt, ...) const libvlc_log_t *ctx, const char *fmt, ...)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment