httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1784318 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/core.xml modules/loggers/mod_syslog.c
Date Fri, 24 Feb 2017 19:39:00 GMT
Author: jim
Date: Fri Feb 24 19:39:00 2017
New Revision: 1784318

URL: http://svn.apache.org/viewvc?rev=1784318&view=rev
Log:
 Support use of optional "tag" in syslog entries. Streamline the patch.
 PR 60525.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/core.xml
    httpd/httpd/trunk/modules/loggers/mod_syslog.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1784318&r1=1784317&r2=1784318&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Feb 24 19:39:00 2017
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_syslog: Support use of optional "tag" in syslog entries.
+     PR 60525. [Ben Rubson <ben.rubson gmail.com>, Jim Jagielski]
+
   *) MPMs unix: Place signals handlers and helpers out of DSOs to avoid
      a possible crash if a signal is caught during (graceful) restart.
      PR 60487.  [Yann Ylavic]

Modified: httpd/httpd/trunk/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=1784318&r1=1784317&r2=1784318&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/core.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/core.xml Fri Feb 24 19:39:00 2017
@@ -1538,7 +1538,7 @@ ErrorDocument 404 /cgi-bin/bad_urls.pl
 <directivesynopsis>
 <name>ErrorLog</name>
 <description>Location where the server will log errors</description>
-<syntax> ErrorLog <var>file-path</var>|syslog[:<var>facility</var>]</syntax>
+<syntax> ErrorLog <var>file-path</var>|syslog[:[<var>facility</var>][:<var>tag</var>]]</syntax>
 <default>ErrorLog logs/error_log (Unix) ErrorLog logs/error.log (Windows and OS/2)</default>
 <contextlist><context>server config</context><context>virtual host</context>
 </contextlist>
@@ -1571,10 +1571,15 @@ ErrorLog "|/usr/local/bin/httpd_errors"
     syntax where <var>facility</var> can be one of the names usually documented
in
     syslog(1).  The facility is effectively global, and if it is changed
     in individual virtual hosts, the final facility specified affects the
-    entire server.</p>
+    entire server. Same rules apply for the syslog tag, which by default
+    uses the Apache binary name, <code>httpd</code> in most cases. You can
+    also override this by using the <code>syslog::<var>tag</var></code>
+    syntax.</p>
 
     <highlight language="config">
 ErrorLog syslog:user
+ErrorLog syslog:user:httpd.srv1
+ErrorLog syslog::httpd.srv2
     </highlight>
 
     <p>Additional modules can provide their own ErrorLog providers. The syntax

Modified: httpd/httpd/trunk/modules/loggers/mod_syslog.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/loggers/mod_syslog.c?rev=1784318&r1=1784317&r2=1784318&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_syslog.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_syslog.c Fri Feb 24 19:39:00 2017
@@ -113,17 +113,37 @@ static void *syslog_error_log_init(apr_p
         openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID, LOG_LOCAL7);
     }
     else {
+        /* s->error_fname could be [level]:[tag] (see #60525) */
+        const char *tag;
+        apr_size_t flen;
         const TRANS *fac;
 
-        for (fac = facilities; fac->t_name; fac++) {
-            if (!strcasecmp(fname, fac->t_name)) {
-                openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID,
-                        fac->t_val);
-                return success;
+        tag = strchr(fname, ':');
+        if (tag) {
+            flen = tag - fname;
+            tag++;
+            if (*tag == '\0') {
+                tag = ap_server_argv0;
             }
+        } else {
+            flen = strlen(fname);
+            tag = ap_server_argv0;
+        }
+        if (flen == 0) {
+            /* Was something like syslog::foobar */
+            openlog(tag, LOG_NDELAY|LOG_CONS|LOG_PID, LOG_LOCAL7);
+        } else {
+            for (fac = facilities; fac->t_name; fac++) {
+                if (!strncasecmp(fname, fac->t_name, flen)) {
+                    openlog(tag, LOG_NDELAY|LOG_CONS|LOG_PID,
+                            fac->t_val);
+                    return success;
+                }
+            }
+            /* Huh? Invalid level name? */
+            return NULL;
         }
     }
-
     return success;
 }
 



Mime
View raw message