You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2014/06/03 15:17:58 UTC
svn commit: r1599535 - in /httpd/httpd/trunk: CHANGES
modules/loggers/mod_log_config.c
Author: covener
Date: Tue Jun 3 13:17:58 2014
New Revision: 1599535
URL: http://svn.apache.org/r1599535
Log:
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
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/loggers/mod_log_config.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1599535&r1=1599534&r2=1599535&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Jun 3 13:17:58 2014
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+ *) mod_log_config: Add GlobalLog to allow a globally defined log to
+ be inherited by virtual hosts that define a CustomLog.
+ [Edward Lu <Chaosed0 gmail.com>]
+
*) MPMs: Support SO_REUSEPORT to create multiple duplicated listener
records for scalability. [Yingqi Lu <yi...@intel.com>,
Jeff Trawick, Jim Jagielski]
Modified: httpd/httpd/trunk/modules/loggers/mod_log_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/loggers/mod_log_config.c?rev=1599535&r1=1599534&r2=1599535&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_log_config.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_log_config.c Tue Jun 3 13:17:58 2014
@@ -262,6 +262,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;
@@ -1171,12 +1172,15 @@ static int multi_log_transaction(request
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);
+ }
}
}
@@ -1301,6 +1305,33 @@ static const char *add_custom_log(cmd_pa
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)
{
@@ -1325,6 +1356,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,