[vlc-devel] commit: logger: add a --syslog-facility option (Pierre Ynard )
git version control
git at videolan.org
Wed May 27 11:40:16 CEST 2009
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Wed May 27 11:29:49 2009 +0200| [3b68fc1354c5050d276fdb917b9730d9cc0d031a] | committer: Pierre Ynard
logger: add a --syslog-facility option
"daemon" is kept as the default, other accepted values are for now
"user" and "local0" through "local7"
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b68fc1354c5050d276fdb917b9730d9cc0d031a
---
modules/misc/logger.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/modules/misc/logger.c b/modules/misc/logger.c
index 88d4962..5a6fe48 100644
--- a/modules/misc/logger.c
+++ b/modules/misc/logger.c
@@ -129,6 +129,16 @@ static const char *const mode_list_text[] = { N_("Text"), "HTML"
"\"text\" (default) and \"html\".")
#endif
+#ifdef HAVE_SYSLOG_H
+static const char *const facility_list[] = { "daemon", "user", "local0",
+ "local1", "local2", "local3", "local4", "local5", "local6", "local7" };
+
+#define SYSLOG_FACILITY_TEXT N_("Syslog facility")
+#define SYSLOG_FACILITY_LONGTEXT N_("Select the syslog facility where logs " \
+ "will be forwarded. Available choices are \"daemon\" (default), \"user\", " \
+ "and \"local0\" through \"local7\".")
+#endif
+
vlc_module_begin ()
set_shortname( N_( "Logging" ) )
set_description( N_("File logging") )
@@ -141,6 +151,11 @@ vlc_module_begin ()
add_string( "logmode", "text", NULL, LOGMODE_TEXT, LOGMODE_LONGTEXT,
false )
change_string_list( mode_list, mode_list_text, 0 )
+#ifdef HAVE_SYSLOG_H
+ add_string( "syslog-facility", "daemon", NULL, SYSLOG_FACILITY_TEXT,
+ SYSLOG_FACILITY_LONGTEXT, true )
+ change_string_list( facility_list, facility_list, 0 )
+#endif
add_obsolete_string( "rrd-file" )
@@ -250,7 +265,42 @@ static int Open( vlc_object_t *p_this )
{
p_sys->msg.p_file = NULL;
#ifdef HAVE_SYSLOG_H
- openlog( "vlc", LOG_PID|LOG_NDELAY, LOG_DAEMON );
+ int i_facility = LOG_DAEMON;
+ char *psz_facility = var_CreateGetString( p_intf, "syslog-facility" );
+ if( psz_facility )
+ {
+ bool b_valid = 0;
+ static const struct { const char *psz_name; int i_value; }
+ p_facility[10] = {
+ { "daemon", LOG_DAEMON }, { "user", LOG_USER },
+ { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 },
+ { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 },
+ { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 },
+ { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }
+ };
+ for( size_t i = 0;
+ i < sizeof( p_facility ) / sizeof( p_facility[0] );
+ i++ )
+ {
+ if( !strcmp( psz_facility, p_facility[i].psz_name ) )
+ {
+ i_facility = p_facility[i].i_value;
+ b_valid = 1;
+ break;
+ }
+ }
+ if( !b_valid )
+ {
+ msg_Warn( p_intf, "invalid syslog facility `%s', using `daemon'", psz_facility );
+ }
+ free( psz_facility );
+ }
+ else
+ {
+ msg_Warn( p_intf, "no syslog facility specified, using `daemon'" );
+ }
+
+ openlog( "vlc", LOG_PID|LOG_NDELAY, i_facility );
#endif
}
More information about the vlc-devel
mailing list