#include <vlc_modules.h>
#include "../libvlc.h"
-#ifdef __ANDROID__
-#include <android/log.h>
-#endif
-
struct vlc_logger_t
{
VLC_COMMON_MEMBERS
* 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)
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)
* \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);
}
}
#endif
-#ifdef __ANDROID__
-static void AndroidPrintMsg (void *d, int type, const vlc_log_t *p_item,
- const char *format, va_list ap)
-{
- int verbose = (intptr_t)d;
- int prio;
-
- if (verbose < 0 || verbose < (type - VLC_MSG_ERR))
- return;
-
- int canc = vlc_savecancel ();
-
- char *format2;
- if (asprintf (&format2, "[%0*"PRIxPTR"] %s %s: %s",
- ptr_width, p_item->i_object_id, p_item->psz_module,
- p_item->psz_object_type, format) < 0)
- return;
- switch (type) {
- case VLC_MSG_INFO:
- prio = ANDROID_LOG_INFO;
- break;
- case VLC_MSG_ERR:
- prio = ANDROID_LOG_ERROR;
- break;
- case VLC_MSG_WARN:
- prio = ANDROID_LOG_WARN;
- break;
- default:
- case VLC_MSG_DBG:
- prio = ANDROID_LOG_DEBUG;
- }
- __android_log_vprint (prio, "VLC", format2, ap);
- free (format2);
- vlc_restorecancel (canc);
-}
-#endif
-
typedef struct vlc_log_early_t
{
struct vlc_log_early_t *next;
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)
module_t *module = vlc_module_load(logger, "logger", NULL, false,
vlc_logger_load, logger, &cb, &sys);
if (module == NULL)
-#ifdef __ANDROID__
- cb = AndroidPrintMsg, sys = NULL;
-#else
cb = vlc_vaLogDiscard;
-#endif
vlc_rwlock_wrlock(&logger->lock);
if (logger->log == vlc_vaLogEarly)