#include <stdarg.h>
#include <assert.h>
+#include <errno.h>
#ifdef __ANDROID__
# include <android/log.h>
*****************************************************************************/
struct intf_sys_t
{
- msg_subscription_t *p_sub;
FILE *p_file;
const char *footer;
+ char *ident;
};
/*****************************************************************************
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
-static void TextPrint(void *, int, const msg_item_t *, const char *, va_list);
-static void HtmlPrint(void *, int, const msg_item_t *, const char *, va_list);
+static void TextPrint(void *, int, const vlc_log_t *, const char *, va_list);
+static void HtmlPrint(void *, int, const vlc_log_t *, const char *, va_list);
#ifdef HAVE_SYSLOG_H
-static void SyslogPrint(void *, int, const msg_item_t *, const char *,
- va_list);
+static void SyslogPrint(void *, int, const vlc_log_t *, const char *, va_list);
#endif
#ifdef __ANDROID__
-static void AndroidPrint(void *, int, const msg_item_t *, const char *, va_list);
+static void AndroidPrint(void *, int, const vlc_log_t *, const char *, va_list);
#endif
/*****************************************************************************
#define LOGMODE_LONGTEXT N_("Specify the logging format.")
#ifdef HAVE_SYSLOG_H
+#define SYSLOG_IDENT_TEXT N_("Syslog ident")
+#define SYSLOG_IDENT_LONGTEXT N_("Set the ident that VLC would use when " \
+ "logging to syslog.")
+
#define SYSLOG_FACILITY_TEXT N_("Syslog facility")
#define SYSLOG_FACILITY_LONGTEXT N_("Select the syslog facility where logs " \
"will be forwarded.")
N_("Log filename"), N_("Specify the log filename."), false )
add_string( "logmode", "text", LOGMODE_TEXT, LOGMODE_LONGTEXT,
false )
- change_string_list( mode_list, mode_list_text, 0 )
+ change_string_list( mode_list, mode_list_text )
#ifdef HAVE_SYSLOG_H
+ add_string( "syslog-ident", "vlc", SYSLOG_IDENT_TEXT,
+ SYSLOG_IDENT_LONGTEXT, true )
add_string( "syslog-facility", fac_name[0], SYSLOG_FACILITY_TEXT,
SYSLOG_FACILITY_LONGTEXT, true )
- change_string_list( fac_name, fac_name, 0 )
+ change_string_list( fac_name, fac_name )
#endif
add_integer( "log-verbose", -1, LOGVERBOSE_TEXT, LOGVERBOSE_LONGTEXT,
false )
return VLC_ENOMEM;
p_sys->p_file = NULL;
- msg_callback_t cb = TextPrint;
+ vlc_log_cb cb = TextPrint;
const char *filename = LOG_FILE_TEXT, *header = TEXT_HEADER;
p_sys->footer = TEXT_FOOTER;
if( !strcmp( mode, "html" ) )
{
p_sys->footer = HTML_FOOTER;
+ filename = LOG_FILE_HTML;
header = HTML_HEADER;
cb = HtmlPrint;
}
i_facility = fac_number[0];
}
- openlog( "vlc", LOG_PID|LOG_NDELAY, i_facility );
+ char *psz_syslog_ident = var_InheritString( p_intf, "syslog-ident" );
+ if (unlikely(psz_syslog_ident == NULL))
+ {
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
+
+ p_sys->ident = psz_syslog_ident;
+ openlog( p_sys->ident, LOG_PID|LOG_NDELAY, i_facility );
+
p_sys->p_file = NULL;
}
else
/* Open the log file and remove any buffering for the stream */
msg_Dbg( p_intf, "opening logfile `%s'", filename );
p_sys->p_file = vlc_fopen( filename, "at" );
- free( psz_file );
if( p_sys->p_file == NULL )
{
- msg_Err( p_intf, "error opening logfile `%s': %m", filename );
+ msg_Err( p_intf, "error opening logfile `%s': %s", filename,
+ vlc_strerror_c(errno) );
+ free( psz_file );
free( p_sys );
return VLC_EGENERIC;
}
+ free( psz_file );
setvbuf( p_sys->p_file, NULL, _IONBF, 0 );
fputs( header, p_sys->p_file );
}
- p_sys->p_sub = vlc_Subscribe( cb, p_intf );
+ vlc_LogSet( p_intf->p_libvlc, cb, p_intf );
return VLC_SUCCESS;
}
intf_sys_t *p_sys = p_intf->p_sys;
/* Flush the queue and unsubscribe from the message queue */
- vlc_Unsubscribe( p_sys->p_sub );
+ vlc_LogSet( p_intf->p_libvlc, NULL, NULL );
/* Close the log file */
#ifdef HAVE_SYSLOG_H
if( p_sys->p_file == NULL )
+ {
closelog();
+ free( p_sys->ident );
+ }
else
#endif
if( p_sys->p_file )
ANDROID_LOG_DEBUG
};
-static void AndroidPrint( void *opaque, int type, const msg_item_t *item,
+static void AndroidPrint( void *opaque, int type, const vlc_log_t *item,
const char *fmt, va_list ap )
{
(void)item;
}
#endif
-static void TextPrint( void *opaque, int type, const msg_item_t *item,
+static void TextPrint( void *opaque, int type, const vlc_log_t *item,
const char *fmt, va_list ap )
{
intf_thread_t *p_intf = opaque;
}
#ifdef HAVE_SYSLOG_H
-static void SyslogPrint( void *opaque, int type, const msg_item_t *item,
+static void SyslogPrint( void *opaque, int type, const vlc_log_t *item,
const char *fmt, va_list ap )
{
static const int i_prio[4] = { LOG_INFO, LOG_ERR, LOG_WARNING, LOG_DEBUG };
}
#endif
-static void HtmlPrint( void *opaque, int type, const msg_item_t *item,
+static void HtmlPrint( void *opaque, int type, const vlc_log_t *item,
const char *fmt, va_list ap )
{
static const unsigned color[4] = {