]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1599535, r1721685 from trunk:
authorJim Jagielski <jim@apache.org>
Wed, 30 Dec 2015 14:48:41 +0000 (14:48 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 30 Dec 2015 14:48:41 +0000 (14:48 +0000)
add GlobalLog directive to allow a diagnostic log to be inherited
by all virtual hosts, even if they define their own logs.

Submitted By: Edward Lu <Chaosed0 gmail.com>
Committed by: covener

document GlobalLog

Submitted by: covener
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1722340 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_log_config.xml
modules/loggers/mod_log_config.c

diff --git a/CHANGES b/CHANGES
index 4f407e8806089e48fd0614a429c60f056ba3624e..3f351ddea932bec10aa259c4939c4d167c743d88 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.4.19
 
+  *) mod_log_config: Add GlobalLog to allow a globally defined log to
+     be inherited by virtual hosts that define a CustomLog.
+     [Edward Lu]
 
 Changes with Apache 2.4.18
 
diff --git a/STATUS b/STATUS
index c467e019e12c09ab9b11b9dc8d276b661268c7ef..7a0a178a450808843075a32664a27dde172cab2a 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -112,13 +112,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_log_config: PR58769: backport GlobalLog directive to 2.4.x
-     trunk patch: http://svn.apache.org/r1599535
-                  http://svn.apache.org/r1721685 
-     2.4.x patch: trunk works
-     +1 covener, jim, ylavic
-     ylavic: note: the CHANGES entry may be modified to remove Ed's email
-             address (leaving the full name only) since he is now a committer.
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
index 59da6ea030822155f9bdb93e901b64e48252f82f..527845e675d0fdd3711c457bbc6a0ea1643f766c 100644 (file)
@@ -585,4 +585,33 @@ TransferLog logs/access_log
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+<name>GlobalLog</name>
+<description>Sets filename and format of log file</description>
+<syntax>GlobalLog  <var>file</var>|<var>pipe</var>|<var>provider</var>
+<var>format</var>|<var>nickname</var>
+[env=[!]<var>environment-variable</var>|
+expr=<var>expression</var>]</syntax>
+<contextlist><context>server config</context>
+</contextlist>
+
+<usage>
+
+    <p>The <directive>GlobalLog</directive> directive defines a log shared
+       by the main server configuration and all defined virtual hosts.</p>
+
+    <p>The <directive>GlobalLog</directive> directive is identical to
+    the <directive>CustomLog</directive> directive, apart from the following
+    differences:</p>
+    <ul>
+       <li><directive>GlobalLog</directive> is not valid in virtual host
+            context.</li>
+       <li><directive>GlobalLog</directive> is used by virtual hosts that
+           define their own <directive>CustomLog</directive>, unlike a 
+           globally specified <directive>CustomLog</directive>.</li>
+    </ul>
+</usage>
+</directivesynopsis>
+
+
 </modulesynopsis>
index 4dd140f60a63f541efac949e8b3039f25d758eb9..b6dc9ff40b731b11126616fe5ce46ca8d7b3de38 100644 (file)
@@ -265,6 +265,7 @@ typedef struct {
     apr_array_header_t *format;
     void *log_writer;
     char *condition_var;
+    int inherit;
     ap_expr_info_t *condition_expr;
     /** place of definition or NULL if already checked */
     const ap_directive_t *directive;
@@ -1206,12 +1207,15 @@ static int multi_log_transaction(request_rec *r)
             config_log_transaction(r, cls, mls->default_format);
         }
     }
-    else if (mls->server_config_logs) {
+
+    if (mls->server_config_logs) {
         clsarray = (config_log_state *) mls->server_config_logs->elts;
         for (i = 0; i < mls->server_config_logs->nelts; ++i) {
             config_log_state *cls = &clsarray[i];
 
-            config_log_transaction(r, cls, mls->default_format);
+            if (cls->inherit || !mls->config_logs->nelts) {
+                config_log_transaction(r, cls, mls->default_format);
+            }
         }
     }
 
@@ -1336,6 +1340,33 @@ static const char *add_custom_log(cmd_parms *cmd, void *dummy, const char *fn,
     return err_string;
 }
 
+static const char *add_global_log(cmd_parms *cmd, void *dummy, const char *fn,
+                                  const char *fmt, const char *envclause) {
+    multi_log_state *mls = ap_get_module_config(cmd->server->module_config,
+                                                &log_config_module);
+    config_log_state *clsarray;
+    config_log_state *cls;
+    const char *ret;
+
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
+    if (err) {
+        return err;
+    }
+
+    /* Add a custom log through the normal channel */
+    ret = add_custom_log(cmd, dummy, fn, fmt, envclause);
+
+    /* Set the inherit flag unless there was some error */
+    if (ret == NULL) {
+        clsarray = (config_log_state*)mls->config_logs->elts;
+        cls = &clsarray[mls->config_logs->nelts-1];
+        cls->inherit = 1;
+    }
+
+    return ret;
+}
+
 static const char *set_transfer_log(cmd_parms *cmd, void *dummy,
                                     const char *fn)
 {
@@ -1360,6 +1391,8 @@ static const command_rec config_log_cmds[] =
 AP_INIT_TAKE23("CustomLog", add_custom_log, NULL, RSRC_CONF,
      "a file name, a custom log format string or format name, "
      "and an optional \"env=\" or \"expr=\" clause (see docs)"),
+AP_INIT_TAKE23("GlobalLog", add_global_log, NULL, RSRC_CONF,
+     "Same as CustomLog, but forces virtualhosts to inherit the log"),
 AP_INIT_TAKE1("TransferLog", set_transfer_log, NULL, RSRC_CONF,
      "the filename of the access log"),
 AP_INIT_TAKE12("LogFormat", log_format, NULL, RSRC_CONF,