[vlc-commits] logger: track file, line and function for debug
Rémi Denis-Courmont
git at videolan.org
Sun Feb 8 13:57:21 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 8 14:23:34 2015 +0200| [c8d5ba620ec54ffb35792777dbdaf5cdb8493281] | committer: Rémi Denis-Courmont
logger: track file, line and function for debug
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8d5ba620ec54ffb35792777dbdaf5cdb8493281
---
include/vlc_messages.h | 37 +++++++++++++++++++++++--------------
src/misc/messages.c | 13 ++++++++++++-
2 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/include/vlc_messages.h b/include/vlc_messages.h
index 045e9e8..2da692e 100644
--- a/include/vlc_messages.h
+++ b/include/vlc_messages.h
@@ -60,23 +60,32 @@ typedef struct vlc_log_t
const char *psz_object_type; /**< Emitter object type name */
const char *psz_module; /**< Emitter module (source code) */
const char *psz_header; /**< Additional header (used by VLM media) */
+ const char *file; /**< Source code file name or NULL */
+ int line; /**< Source code file line number or -1 */
+ const char *func; /**< Source code calling function name or NULL */
} vlc_log_t;
-VLC_API void vlc_Log(vlc_object_t *, int,
- const char *, const char *, ...) VLC_FORMAT( 4, 5 );
-VLC_API void vlc_vaLog(vlc_object_t *, int,
- const char *, const char *, va_list);
-#define msg_GenericVa(a, b, c, d) \
- vlc_vaLog(VLC_OBJECT(a), b, MODULE_STRING, c, d)
+VLC_API void vlc_Log(vlc_object_t *obj, int prio, const char *module,
+ const char *file, unsigned line, const char *func,
+ const char *format, ...) VLC_FORMAT(7, 8);
+VLC_API void vlc_vaLog(vlc_object_t *obj, int prio, const char *module,
+ const char *file, unsigned line, const char *func,
+ const char *format, va_list ap);
+#define msg_GenericVa(o, p, fmt, ap) \
+ vlc_vaLog(VLC_OBJECT(o), p, MODULE_STRING, __FILE__, __LINE__, __func__, \
+ fmt, ap)
-#define msg_Info( p_this, ... ) \
- vlc_Log( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, __VA_ARGS__ )
-#define msg_Err( p_this, ... ) \
- vlc_Log( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, __VA_ARGS__ )
-#define msg_Warn( p_this, ... ) \
- vlc_Log( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, __VA_ARGS__ )
-#define msg_Dbg( p_this, ... ) \
- vlc_Log( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, __VA_ARGS__ )
+#define msg_Generic(o, p, ...) \
+ vlc_Log(VLC_OBJECT(o), p, MODULE_STRING, __FILE__, __LINE__, \
+ __func__, __VA_ARGS__)
+#define msg_Info(p_this, ...) \
+ msg_Generic(p_this, VLC_MSG_INFO, __VA_ARGS__)
+#define msg_Err(p_this, ...) \
+ msg_Generic(p_this, VLC_MSG_ERR, __VA_ARGS__)
+#define msg_Warn(p_this, ...) \
+ msg_Generic(p_this, VLC_MSG_WARN, __VA_ARGS__)
+#define msg_Dbg(p_this, ...) \
+ msg_Generic(p_this, VLC_MSG_DBG, __VA_ARGS__)
#ifndef MODULE_STRING
# define MODULE_STRING __FILE__
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 77a5ec9..3679ade 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -88,6 +88,7 @@ static void Win32DebugOutputMsg (void *, int , const vlc_log_t *,
* to vlc_Log().
*/
void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
+ const char *file, unsigned line, const char *func,
const char *format, va_list args)
{
if (obj != NULL && obj->i_flags & OBJECT_FLAGS_QUIET)
@@ -115,6 +116,9 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
msg.psz_object_type = (obj != NULL) ? obj->psz_object_type : "generic";
msg.psz_module = module;
msg.psz_header = NULL;
+ msg.file = file;
+ msg.line = line;
+ msg.func = func;
for (vlc_object_t *o = obj; o != NULL; o = o->p_parent)
if (o->psz_header != NULL)
@@ -142,15 +146,19 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
* \param type VLC_MSG_* message type (info, error, warning or debug)
* \param module name of module from which the message come
* (normally MODULE_STRING)
+ * \param file source module file name (normally __FILE__) or NULL
+ * \param line function call source line number (normally __LINE__) or 0
+ * \param func calling function name (normally __func__) or NULL
* \param format printf-like message format
*/
void vlc_Log(vlc_object_t *obj, int type, const char *module,
+ const char *file, unsigned line, const char *func,
const char *format, ... )
{
va_list ap;
va_start(ap, format);
- vlc_vaLog(obj, type, module, format, ap);
+ vlc_vaLog(obj, type, module, file, line, func, format, ap);
va_end(ap);
}
@@ -265,6 +273,9 @@ static void vlc_vaLogEarly(void *d, int type, const vlc_log_t *item,
log->meta.psz_object_type = item->psz_object_type;
log->meta.psz_module = item->psz_module; /* Ditto. */
log->meta.psz_header = item->psz_header ? strdup(item->psz_header) : NULL;
+ log->meta.file = item->file;
+ log->meta.line = item->line;
+ log->meta.func = item->func;
int canc = vlc_savecancel(); /* XXX: needed for vasprintf() ? */
if (vasprintf(&log->msg, format, ap) == -1)
More information about the vlc-commits
mailing list