2002-08-04 19:23:44 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* logger.c : file logging plugin for vlc
|
|
|
|
*****************************************************************************
|
2008-10-12 16:30:30 +02:00
|
|
|
* Copyright (C) 2002-2008 the VideoLAN team
|
2004-03-06 16:24:37 +01:00
|
|
|
* $Id$
|
2002-08-04 19:23:44 +02:00
|
|
|
*
|
|
|
|
* Authors: Samuel Hocevar <sam@zoy.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2005-01-29 16:22:53 +01:00
|
|
|
*
|
2002-08-04 19:23:44 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-07-27 11:41:22 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2002-08-04 19:23:44 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Preamble
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2008-01-23 22:50:58 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-05-31 20:49:57 +02:00
|
|
|
#include <vlc_common.h>
|
2008-05-08 17:30:33 +02:00
|
|
|
#include <vlc_plugin.h>
|
2007-09-05 15:51:21 +02:00
|
|
|
#include <vlc_interface.h>
|
2010-02-07 14:18:02 +01:00
|
|
|
#include <vlc_fs.h>
|
2010-07-22 19:25:48 +02:00
|
|
|
#include <vlc_charset.h>
|
2007-09-05 15:51:21 +02:00
|
|
|
|
2011-08-20 22:34:43 +02:00
|
|
|
#include <stdarg.h>
|
2008-10-12 16:28:38 +02:00
|
|
|
#include <assert.h>
|
2002-08-04 19:23:44 +02:00
|
|
|
|
|
|
|
#define MODE_TEXT 0
|
|
|
|
#define MODE_HTML 1
|
2005-11-30 00:12:52 +01:00
|
|
|
#define MODE_SYSLOG 2
|
2002-08-04 19:23:44 +02:00
|
|
|
|
2006-02-01 14:01:06 +01:00
|
|
|
#ifdef __APPLE__
|
2004-03-27 18:36:46 +01:00
|
|
|
#define LOG_DIR "Library/Logs/"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LOG_FILE_TEXT "vlc-log.txt"
|
|
|
|
#define LOG_FILE_HTML "vlc-log.html"
|
|
|
|
|
2011-09-22 15:32:23 +02:00
|
|
|
#define TEXT_HEADER "\xEF\xBB\xBF-- logger module started --\n"
|
2002-08-04 19:23:44 +02:00
|
|
|
#define TEXT_FOOTER "-- logger module stopped --\n"
|
|
|
|
|
|
|
|
#define HTML_HEADER \
|
2007-09-13 18:26:28 +02:00
|
|
|
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n" \
|
|
|
|
" \"http://www.w3.org/TR/html4/strict.dtd\">\n" \
|
2002-08-04 19:23:44 +02:00
|
|
|
"<html>\n" \
|
|
|
|
" <head>\n" \
|
|
|
|
" <title>vlc log</title>\n" \
|
2007-09-13 18:24:27 +02:00
|
|
|
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" \
|
2002-08-04 19:23:44 +02:00
|
|
|
" </head>\n" \
|
2007-09-13 18:24:27 +02:00
|
|
|
" <body style=\"background-color: #000000; color: #aaaaaa;\">\n" \
|
2002-08-04 19:23:44 +02:00
|
|
|
" <pre>\n" \
|
2011-09-22 15:31:50 +02:00
|
|
|
" <strong>-- logger module started --</strong>\n"
|
2002-08-04 19:23:44 +02:00
|
|
|
#define HTML_FOOTER \
|
2011-09-22 15:31:50 +02:00
|
|
|
" <strong>-- logger module stopped --</strong>\n" \
|
2002-08-04 19:23:44 +02:00
|
|
|
" </pre>\n" \
|
|
|
|
" </body>\n" \
|
|
|
|
"</html>\n"
|
|
|
|
|
2009-08-31 11:10:22 +02:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2005-11-30 00:12:52 +01:00
|
|
|
#include <syslog.h>
|
|
|
|
#endif
|
|
|
|
|
2002-08-04 19:23:44 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* intf_sys_t: description and status of log interface
|
|
|
|
*****************************************************************************/
|
|
|
|
struct intf_sys_t
|
|
|
|
{
|
|
|
|
msg_subscription_t *p_sub;
|
2011-08-19 21:27:41 +02:00
|
|
|
FILE *p_file;
|
2011-08-20 23:05:33 +02:00
|
|
|
const char *footer;
|
2002-08-04 19:23:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Local prototypes
|
|
|
|
*****************************************************************************/
|
2005-01-29 16:22:53 +01:00
|
|
|
static int Open ( vlc_object_t * );
|
2002-08-04 19:23:44 +02:00
|
|
|
static void Close ( vlc_object_t * );
|
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
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);
|
2005-11-30 00:12:52 +01:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2011-08-20 23:05:33 +02:00
|
|
|
static void SyslogPrint(void *, int, const msg_item_t *, const char *,
|
|
|
|
va_list);
|
2005-11-30 00:12:52 +01:00
|
|
|
#endif
|
2002-08-04 19:23:44 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Module descriptor
|
|
|
|
*****************************************************************************/
|
2008-05-27 21:16:52 +02:00
|
|
|
static const char *const mode_list[] = { "text", "html"
|
2005-11-30 00:12:52 +01:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
,"syslog"
|
|
|
|
#endif
|
|
|
|
};
|
2008-05-27 21:16:52 +02:00
|
|
|
static const char *const mode_list_text[] = { N_("Text"), "HTML"
|
2005-11-30 00:12:52 +01:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
, "syslog"
|
|
|
|
#endif
|
|
|
|
};
|
2003-11-05 01:39:17 +01:00
|
|
|
|
2003-05-16 00:27:38 +02:00
|
|
|
#define LOGMODE_TEXT N_("Log format")
|
2009-07-27 11:41:22 +02:00
|
|
|
#ifndef HAVE_SYSLOG_H
|
2006-03-22 13:14:30 +01:00
|
|
|
#define LOGMODE_LONGTEXT N_("Specify the log format. Available choices are " \
|
2006-03-22 15:14:10 +01:00
|
|
|
"\"text\" (default) and \"html\".")
|
2009-07-27 11:41:22 +02:00
|
|
|
#else
|
2003-05-16 00:27:38 +02:00
|
|
|
|
2009-07-27 11:41:22 +02:00
|
|
|
#define LOGMODE_LONGTEXT N_("Specify the log format. Available choices are " \
|
|
|
|
"\"text\" (default), \"html\", and \"syslog\" (special mode to send to " \
|
|
|
|
"syslog instead of file.")
|
2009-05-27 11:29:49 +02:00
|
|
|
|
|
|
|
#define SYSLOG_FACILITY_TEXT N_("Syslog facility")
|
|
|
|
#define SYSLOG_FACILITY_LONGTEXT N_("Select the syslog facility where logs " \
|
2009-07-27 11:41:22 +02:00
|
|
|
"will be forwarded. Available choices are \"user\" (default), \"daemon\", " \
|
2009-05-27 11:29:49 +02:00
|
|
|
"and \"local0\" through \"local7\".")
|
2009-07-27 11:41:22 +02:00
|
|
|
|
|
|
|
/* First in list is the default facility used. */
|
|
|
|
#define DEFINE_SYSLOG_FACILITY \
|
|
|
|
DEF( "user", LOG_USER ), \
|
|
|
|
DEF( "daemon", LOG_DAEMON ), \
|
|
|
|
DEF( "local0", LOG_LOCAL0 ), \
|
|
|
|
DEF( "local1", LOG_LOCAL1 ), \
|
|
|
|
DEF( "local2", LOG_LOCAL2 ), \
|
|
|
|
DEF( "local3", LOG_LOCAL3 ), \
|
|
|
|
DEF( "local4", LOG_LOCAL4 ), \
|
|
|
|
DEF( "local5", LOG_LOCAL5 ), \
|
|
|
|
DEF( "local6", LOG_LOCAL6 ), \
|
|
|
|
DEF( "local7", LOG_LOCAL7 )
|
|
|
|
|
|
|
|
#define DEF( a, b ) a
|
|
|
|
static const char *const fac_name[] = { DEFINE_SYSLOG_FACILITY };
|
|
|
|
#undef DEF
|
|
|
|
#define DEF( a, b ) b
|
|
|
|
static const int fac_number[] = { DEFINE_SYSLOG_FACILITY };
|
|
|
|
#undef DEF
|
|
|
|
enum { fac_entries = sizeof(fac_name)/sizeof(fac_name[0]) };
|
|
|
|
#undef DEFINE_SYSLOG_FACILITY
|
|
|
|
|
2009-05-27 11:29:49 +02:00
|
|
|
#endif
|
|
|
|
|
2010-01-01 00:57:52 +01:00
|
|
|
#define LOGVERBOSE_TEXT N_("Verbosity")
|
|
|
|
#define LOGVERBOSE_LONGTEXT N_("Select the verbosity to use for log or -1 to " \
|
|
|
|
"use the same verbosity given by --verbose.")
|
|
|
|
|
2008-10-29 20:59:01 +01:00
|
|
|
vlc_module_begin ()
|
|
|
|
set_shortname( N_( "Logging" ) )
|
|
|
|
set_description( N_("File logging") )
|
2004-01-25 18:52:17 +01:00
|
|
|
|
2008-10-29 20:59:01 +01:00
|
|
|
set_category( CAT_ADVANCED )
|
|
|
|
set_subcategory( SUBCAT_ADVANCED_MISC )
|
2006-03-09 20:55:40 +01:00
|
|
|
|
2010-10-22 19:54:03 +02:00
|
|
|
add_savefile( "logfile", NULL,
|
2009-01-28 20:48:19 +01:00
|
|
|
N_("Log filename"), N_("Specify the log filename."), false )
|
2010-10-22 19:19:38 +02:00
|
|
|
add_string( "logmode", "text", LOGMODE_TEXT, LOGMODE_LONGTEXT,
|
2009-01-27 22:22:05 +01:00
|
|
|
false )
|
2009-01-28 20:48:19 +01:00
|
|
|
change_string_list( mode_list, mode_list_text, 0 )
|
2009-05-27 11:29:49 +02:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2010-10-22 19:19:38 +02:00
|
|
|
add_string( "syslog-facility", fac_name[0], SYSLOG_FACILITY_TEXT,
|
2009-05-27 11:29:49 +02:00
|
|
|
SYSLOG_FACILITY_LONGTEXT, true )
|
2009-07-27 11:41:22 +02:00
|
|
|
change_string_list( fac_name, fac_name, 0 )
|
2009-05-27 11:29:49 +02:00
|
|
|
#endif
|
2010-10-22 20:05:50 +02:00
|
|
|
add_integer( "log-verbose", -1, LOGVERBOSE_TEXT, LOGVERBOSE_LONGTEXT,
|
2009-12-30 14:19:05 +01:00
|
|
|
false )
|
|
|
|
|
2009-02-28 18:15:59 +01:00
|
|
|
add_obsolete_string( "rrd-file" )
|
2006-01-28 11:56:47 +01:00
|
|
|
|
2008-10-29 20:59:01 +01:00
|
|
|
set_capability( "interface", 0 )
|
|
|
|
set_callbacks( Open, Close )
|
|
|
|
vlc_module_end ()
|
2002-08-04 19:23:44 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Open: initialize and create stuff
|
|
|
|
*****************************************************************************/
|
|
|
|
static int Open( vlc_object_t *p_this )
|
2005-11-30 00:12:52 +01:00
|
|
|
{
|
2002-08-04 19:23:44 +02:00
|
|
|
intf_thread_t *p_intf = (intf_thread_t *)p_this;
|
2008-10-12 16:28:30 +02:00
|
|
|
intf_sys_t *p_sys;
|
2002-08-04 19:23:44 +02:00
|
|
|
|
2002-10-03 19:01:59 +02:00
|
|
|
CONSOLE_INTRO_MSG;
|
2009-07-27 11:41:22 +02:00
|
|
|
msg_Info( p_intf, "using logger." );
|
2002-08-04 19:23:44 +02:00
|
|
|
|
|
|
|
/* Allocate instance and initialize some members */
|
2008-10-12 16:28:30 +02:00
|
|
|
p_sys = p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
|
|
|
|
if( p_sys == NULL )
|
|
|
|
return VLC_ENOMEM;
|
2002-08-04 19:23:44 +02:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
msg_callback_t cb = TextPrint;
|
|
|
|
const char *filename = LOG_FILE_TEXT, *header = TEXT_HEADER;
|
|
|
|
p_sys->footer = TEXT_FOOTER;
|
|
|
|
|
|
|
|
char *mode = var_InheritString( p_intf, "logmode" );
|
|
|
|
if( mode != NULL )
|
2002-08-04 19:23:44 +02:00
|
|
|
{
|
2011-08-20 23:05:33 +02:00
|
|
|
if( !strcmp( mode, "html" ) )
|
2002-08-04 19:23:44 +02:00
|
|
|
{
|
2011-08-20 23:05:33 +02:00
|
|
|
p_sys->footer = HTML_FOOTER;
|
|
|
|
header = HTML_HEADER;
|
|
|
|
cb = HtmlPrint;
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
2005-11-30 00:12:52 +01:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2011-08-20 23:05:33 +02:00
|
|
|
else if( !strcmp( mode, "syslog" ) )
|
|
|
|
cb = SyslogPrint;
|
2005-11-30 00:12:52 +01:00
|
|
|
#endif
|
2011-08-20 23:05:33 +02:00
|
|
|
else if( strcmp( mode, "text" ) )
|
|
|
|
msg_Warn( p_intf, "invalid log mode `%s', using `text'", mode );
|
|
|
|
free( mode );
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
2005-11-30 00:12:52 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
2011-08-20 23:05:33 +02:00
|
|
|
if( cb == SyslogPrint )
|
|
|
|
{
|
2009-07-27 11:41:22 +02:00
|
|
|
int i_facility;
|
2010-10-08 20:58:18 +02:00
|
|
|
char *psz_facility = var_InheritString( p_intf, "syslog-facility" );
|
2009-05-27 11:29:49 +02:00
|
|
|
if( psz_facility )
|
|
|
|
{
|
|
|
|
bool b_valid = 0;
|
2009-07-27 11:41:22 +02:00
|
|
|
for( size_t i = 0; i < fac_entries; ++i )
|
2009-05-27 11:29:49 +02:00
|
|
|
{
|
2009-07-27 11:41:22 +02:00
|
|
|
if( !strcmp( psz_facility, fac_name[i] ) )
|
2009-05-27 11:29:49 +02:00
|
|
|
{
|
2009-07-27 11:41:22 +02:00
|
|
|
i_facility = fac_number[i];
|
2009-05-27 11:29:49 +02:00
|
|
|
b_valid = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( !b_valid )
|
|
|
|
{
|
2009-07-27 11:41:22 +02:00
|
|
|
msg_Warn( p_intf, "invalid syslog facility `%s', using `%s'",
|
|
|
|
psz_facility, fac_name[0] );
|
|
|
|
i_facility = fac_number[0];
|
2009-05-27 11:29:49 +02:00
|
|
|
}
|
|
|
|
free( psz_facility );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-27 11:41:22 +02:00
|
|
|
msg_Warn( p_intf, "no syslog facility specified, using `%s'",
|
|
|
|
fac_name[0] );
|
|
|
|
i_facility = fac_number[0];
|
2009-05-27 11:29:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
openlog( "vlc", LOG_PID|LOG_NDELAY, i_facility );
|
2011-08-20 23:05:33 +02:00
|
|
|
p_sys->p_file = NULL;
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
2011-08-20 23:05:33 +02:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
char *psz_file = var_InheritString( p_intf, "logfile" );
|
|
|
|
if( !psz_file )
|
|
|
|
{
|
|
|
|
#ifdef __APPLE__
|
|
|
|
char *home = config_GetUserDir(VLC_DOCUMENTS_DIR);
|
|
|
|
if( home == NULL
|
|
|
|
|| asprintf( &psz_file, "%s/"LOG_DIR"/%s", home,
|
|
|
|
filename ) == -1 )
|
|
|
|
psz_file = NULL;
|
|
|
|
free(home);
|
|
|
|
filename = psz_file;
|
|
|
|
#endif
|
|
|
|
msg_Warn( p_intf, "no log filename provided, using `%s'",
|
|
|
|
filename );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
filename = psz_file;
|
2002-08-04 19:23:44 +02:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
/* 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 );
|
|
|
|
free( p_sys );
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
setvbuf( p_sys->p_file, NULL, _IONBF, 0 );
|
|
|
|
fputs( header, p_sys->p_file );
|
|
|
|
}
|
2002-08-24 19:04:36 +02:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
p_sys->p_sub = vlc_Subscribe( cb, p_intf );
|
|
|
|
return VLC_SUCCESS;
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Close: destroy interface stuff
|
|
|
|
*****************************************************************************/
|
|
|
|
static void Close( vlc_object_t *p_this )
|
2005-11-30 00:12:52 +01:00
|
|
|
{
|
2002-08-04 19:23:44 +02:00
|
|
|
intf_thread_t *p_intf = (intf_thread_t *)p_this;
|
2008-10-12 16:28:38 +02:00
|
|
|
intf_sys_t *p_sys = p_intf->p_sys;
|
|
|
|
|
2002-08-04 19:23:44 +02:00
|
|
|
/* Flush the queue and unsubscribe from the message queue */
|
2011-08-19 20:38:16 +02:00
|
|
|
vlc_Unsubscribe( p_sys->p_sub );
|
2002-08-04 19:23:44 +02:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
/* Close the log file */
|
2005-11-30 00:12:52 +01:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2011-08-20 23:05:33 +02:00
|
|
|
if( p_sys->p_file == NULL )
|
2005-11-30 00:12:52 +01:00
|
|
|
closelog();
|
2011-08-20 23:05:33 +02:00
|
|
|
else
|
2005-11-30 00:12:52 +01:00
|
|
|
#endif
|
2011-08-20 23:05:33 +02:00
|
|
|
{
|
|
|
|
fputs( p_sys->footer, p_sys->p_file );
|
2011-08-19 21:27:41 +02:00
|
|
|
fclose( p_sys->p_file );
|
2011-08-20 23:05:33 +02:00
|
|
|
}
|
2002-08-04 19:23:44 +02:00
|
|
|
|
|
|
|
/* Destroy structure */
|
2008-10-12 16:28:30 +02:00
|
|
|
free( p_sys );
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
static bool IgnoreMessage( intf_thread_t *p_intf, int type )
|
2002-08-04 19:23:44 +02:00
|
|
|
{
|
2011-08-20 22:34:43 +02:00
|
|
|
/* TODO: cache value... */
|
2011-08-19 21:27:41 +02:00
|
|
|
int verbosity = var_InheritInteger( p_intf, "log-verbose" );
|
2009-12-30 14:19:05 +01:00
|
|
|
if (verbosity == -1)
|
2011-08-19 21:27:41 +02:00
|
|
|
verbosity = var_InheritInteger( p_intf, "verbose" );
|
2008-10-12 21:41:13 +02:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
return verbosity < 0 || verbosity < (type - VLC_MSG_ERR);
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
/*
|
|
|
|
* Logging callbacks
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const char ppsz_type[4][9] = {
|
|
|
|
"",
|
|
|
|
" error",
|
|
|
|
" warning",
|
|
|
|
" debug",
|
2008-10-12 18:25:06 +02:00
|
|
|
};
|
2002-08-04 19:23:44 +02:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
static void TextPrint( void *opaque, int type, const msg_item_t *item,
|
|
|
|
const char *fmt, va_list ap )
|
2002-08-04 19:23:44 +02:00
|
|
|
{
|
2011-08-20 23:05:33 +02:00
|
|
|
intf_thread_t *p_intf = opaque;
|
|
|
|
FILE *stream = p_intf->p_sys->p_file;
|
|
|
|
|
|
|
|
if( IgnoreMessage( p_intf, type ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int canc = vlc_savecancel();
|
|
|
|
flockfile( stream );
|
2011-09-22 15:32:23 +02:00
|
|
|
fprintf( stream, "%s%s: ", item->psz_module, ppsz_type[type] );
|
|
|
|
vfprintf( stream, fmt, ap );
|
2011-08-21 10:23:57 +02:00
|
|
|
putc_unlocked( '\n', stream );
|
2011-08-20 23:05:33 +02:00
|
|
|
funlockfile( stream );
|
|
|
|
vlc_restorecancel( canc );
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|
|
|
|
|
2005-11-30 00:12:52 +01:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2011-08-20 23:05:33 +02:00
|
|
|
static void SyslogPrint( void *opaque, int type, const msg_item_t *item,
|
|
|
|
const char *fmt, va_list ap )
|
2005-11-30 00:12:52 +01:00
|
|
|
{
|
2008-03-12 23:13:11 +01:00
|
|
|
static const int i_prio[4] = { LOG_INFO, LOG_ERR, LOG_WARNING, LOG_DEBUG };
|
2011-08-20 23:05:33 +02:00
|
|
|
|
|
|
|
intf_thread_t *p_intf = opaque;
|
|
|
|
char *str;
|
2011-08-20 22:34:43 +02:00
|
|
|
int i_priority = i_prio[type];
|
2005-11-30 00:12:52 +01:00
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
if( IgnoreMessage( p_intf, type )
|
|
|
|
|| unlikely(vasprintf( &str, fmt, ap ) == -1) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int canc = vlc_savecancel();
|
2011-08-20 22:34:43 +02:00
|
|
|
if( item->psz_header != NULL )
|
2011-08-20 23:05:33 +02:00
|
|
|
syslog( i_priority, "[%s] %s%s: %s", item->psz_header,
|
2011-08-20 22:34:43 +02:00
|
|
|
item->psz_module, ppsz_type[type], str );
|
2006-01-31 16:11:08 +01:00
|
|
|
else
|
2011-08-20 23:05:33 +02:00
|
|
|
syslog( i_priority, "%s%s: %s",
|
2011-08-20 22:34:43 +02:00
|
|
|
item->psz_module, ppsz_type[type], str );
|
2011-08-20 23:05:33 +02:00
|
|
|
vlc_restorecancel( canc );
|
|
|
|
free( str );
|
2005-11-30 00:12:52 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
static void HtmlPrint( void *opaque, int type, const msg_item_t *item,
|
|
|
|
const char *fmt, va_list ap )
|
2002-08-04 19:23:44 +02:00
|
|
|
{
|
2011-08-20 23:05:33 +02:00
|
|
|
static const unsigned color[4] = {
|
|
|
|
0xffffff, 0xff6666, 0xffff66, 0xaaaaaa,
|
2008-10-12 18:25:06 +02:00
|
|
|
};
|
|
|
|
|
2011-08-20 23:05:33 +02:00
|
|
|
intf_thread_t *p_intf = opaque;
|
|
|
|
FILE *stream = p_intf->p_sys->p_file;
|
|
|
|
|
|
|
|
if( IgnoreMessage( p_intf, type ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int canc = vlc_savecancel();
|
|
|
|
flockfile( stream );
|
|
|
|
fprintf( stream, "%s%s: <span style=\"color: #%06x\">",
|
|
|
|
item->psz_module, ppsz_type[type], color[type] );
|
|
|
|
/* FIXME: encode special ASCII characters */
|
|
|
|
fprintf( stream, fmt, ap );
|
|
|
|
fputs( "</span>\n", stream );
|
|
|
|
funlockfile( stream );
|
|
|
|
vlc_restorecancel( canc );
|
2002-08-04 19:23:44 +02:00
|
|
|
}
|