[vlc-devel] [PATCH] logger: Add --syslog-ident parameter.

Georgi Chorbadzhiyski gf at unixsol.org
Wed Mar 6 17:17:47 CET 2013

Around 03/06/2013 05:57 PM, Rémi Denis-Courmont scribbled:
> Le mercredi 6 mars 2013 17:02:34, Georgi Chorbadzhiyski a écrit :
>> Around 03/06/2013 04:39 PM, Rémi Denis-Courmont scribbled:
>>> On Wed,  6 Mar 2013 15:10:22 +0200, Georgi Chorbadzhiyski
>>> <gf at unixsol.org>
>>> wrote:
>>>> By default VLC uses "vlc" as syslog ident but in case more than one
>>>> VLC is logging this may not be enough.
>>> Even if there are more than one concurrent VLC process, each of them has
>>> a contemporarily unique process identifier. That is why the LOG_PID flag
>>> is set. The issue you describe does not exist.
>> I runs tens of VLC instances each transcoding single channel and logs go to
>> another machine via syslog. Without ident how can I make the connection
>> between the pid and the channel name and each log in different file?
> Presumably syslog includes the host identifier as well. Regardless, the case of 
> multiple hosts is not mentioned in your patch comments, so nobody could 
> possibly guess that was the problem.

Yes it includes it, but when all processes identify themselves as vlc I have no
way of knowing which of them is talking when there are 10 VLC's on host X.
I've seen other daemons that don't offer way of setting syslog-ident use
argv[0] as the ident /that would also work for me/.

>> Sure,
>> I can make syslog-ng name files based on the pid but that would not be
>> very friendly.
>> Pretty much every program that offers syslog support allows setting of the
>> ident.
> Usually, you can customize the facility, sometimes the level. I have yet to 
> find a daemon sporting custom identity.
> In any case, your patch fails to deal with error and leaks memory.

Little vague, do you mean that I have to free the result of

var_InheritString( p_intf, "syslog-ident" )

Corrected patch is attached.

Georgi Chorbadzhiyski
-------------- next part --------------
From 66e3b927af13f3162cb81f5d69cf554ede54e3eb Mon Sep 17 00:00:00 2001
From: Georgi Chorbadzhiyski <gf at unixsol.org>
Date: Wed, 6 Mar 2013 14:59:13 +0200
Subject: [PATCH] logger: Add --syslog-ident parameter.

By default VLC uses "vlc" as syslog ident but in case more than one
VLC is running on the host it is difficult to distinguish what different
processes are logging. The pid is not enough and may not even make sense
when sysloged messages are sent to another host.

This commit introduces --syslog-ident parameter which allows setting
of the ident.
 modules/misc/logger.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/misc/logger.c b/modules/misc/logger.c
index ea827ea..ab64924 100644
--- a/modules/misc/logger.c
+++ b/modules/misc/logger.c
@@ -119,6 +119,10 @@ static const char *const mode_list_text[] = { N_("Text"), "HTML"
 #define LOGMODE_LONGTEXT N_("Specify the logging format.")
+#define SYSLOG_IDENT_TEXT N_("Syslog ident")
+#define SYSLOG_IDENT_LONGTEXT N_("Set the ident that VLC would use when " \
+  "logging to syslog. Default ident: vlc")
 #define SYSLOG_FACILITY_TEXT N_("Syslog facility")
 #define SYSLOG_FACILITY_LONGTEXT N_("Select the syslog facility where logs " \
   "will be forwarded.")
@@ -164,6 +168,8 @@ vlc_module_begin ()
                 false )
         change_string_list( mode_list, mode_list_text )
+    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 )
@@ -252,7 +258,10 @@ static int Open( vlc_object_t *p_this )
             i_facility = fac_number[0];
-        openlog( "vlc", LOG_PID|LOG_NDELAY, i_facility );
+        char *syslog_ident = var_InheritString( p_intf, "syslog-ident" );
+        openlog( syslog_ident, LOG_PID|LOG_NDELAY, i_facility );
+        free( syslog_ident );
         p_sys->p_file = NULL;

More information about the vlc-devel mailing list