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

Georgi Chorbadzhiyski gf at unixsol.org
Wed Mar 6 19:36:54 CET 2013


On 06.3.2013 г. 20:18, Rémi Denis-Courmont wrote:
> Le mercredi 6 mars 2013 20:01:00, Georgi Chorbadzhiyski a écrit :
>> I assumed that the second parameter to add_string() sets the default value
>> and can't get NULL. As for freeing I have fixed that. If I can get NULL
>> when second parameter to add_string() is set, the attached patch should be
>> ok.
>
> Please don't duplicate the default value in the help text. It's already shown
> automatically.

So the second parameter to add_string() is the default value, right /it looks
that way reading the code/? How can I get NULL from inherit_var, shouldn't I
get the default value when option is not set by the user?

>>> Normally, there is only one VLC with a given PID on a given host...
>>
>> I don't use VLC as player but as encoder/transcoder for lots of channels
>> /tens per host/. My usage is absolutely not the normal one.
>
> That changes nothing to the fact that there is only one "vlc" process with a
> certain PID at a certain time on a certain machine. Hence, it is always
> possible to uniquely identify a VLC instance in the logs.

Yes, but how to know that vlc[1234] is the vlc that currently transcodes
channel ABC. I don't dispute that vlc[PID] is sort of uniq identifier,
my point is that vlc[1234] is not enough for syslog server to know that
these messages should go into $HOST/$YEAR-$MONTH-$DAY/transcode-$IDENT.log

-- 
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
-------------- next part --------------
From 4de85eec54168f7021fb4da1cec60e07589dc3fe 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 | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/modules/misc/logger.c b/modules/misc/logger.c
index ea827ea..440c818 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.")
 
 #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.")
@@ -164,6 +168,8 @@ vlc_module_begin ()
                 false )
         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 )
@@ -252,7 +258,11 @@ 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" );
+        const char *ident = syslog_ident ? syslog_ident : "vlc";
+        openlog( ident, LOG_PID|LOG_NDELAY, i_facility );
+        free( syslog_ident );
+
         p_sys->p_file = NULL;
     }
     else
-- 
1.8.1.4



More information about the vlc-devel mailing list