You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2010/09/12 14:59:11 UTC
svn commit: r996307 - in /httpd/httpd/trunk: docs/manual/mod/core.xml
server/log.c
Author: sf
Date: Sun Sep 12 12:59:10 2010
New Revision: 996307
URL: http://svn.apache.org/viewvc?rev=996307&view=rev
Log:
add errorlog formats for request notes and env vars
Modified:
httpd/httpd/trunk/docs/manual/mod/core.xml
httpd/httpd/trunk/server/log.c
Modified: httpd/httpd/trunk/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=996307&r1=996306&r2=996307&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/core.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/core.xml Sun Sep 12 12:59:10 2010
@@ -1106,6 +1106,9 @@ in case of an error</description>
<tr><td><code>%...A</code></td>
<td>Local IP-address and port</td></tr>
+ <tr><td><code>%...{name}e</code></td>
+ <td>Request environment variable <code>name</code></td></tr>
+
<tr><td><code>%...E</code></td>
<td>APR/OS error status code and string</td></tr>
@@ -1136,6 +1139,9 @@ in case of an error</description>
<tr><td><code>%M</code></td>
<td>The actual log message</td></tr>
+ <tr><td><code>%...{name}n</code></td>
+ <td>Request note <code>name</code></td></tr>
+
<tr><td><code>%...P</code></td>
<td>Process ID of current process</td></tr>
Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=996307&r1=996306&r2=996307&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Sun Sep 12 12:59:10 2010
@@ -736,38 +736,57 @@ static int log_apr_status(const ap_error
return len;
}
-static int log_header(const ap_errorlog_info *info, const char *arg,
- char *buf, int buflen)
+static int log_table_entry(const apr_table_t *table, const char *name,
+ char *buf, int buflen)
{
- const char *header;
- int len = 0;
#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
+ const char *value;
char scratch[MAX_STRING_LEN];
-#endif
- if ( info->r && (header = apr_table_get(info->r->headers_in, arg))
-#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
- && ap_escape_errorlog_item(scratch, header, MAX_STRING_LEN)
-#endif
- ) {
- len = cpystrn(buf,
-#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
- scratch,
+ if ((value = apr_table_get(table, name)) != NULL) {
+ ap_escape_errorlog_item(scratch, value, MAX_STRING_LEN);
+ return cpystrn(buf, scratch, buflen);
+ }
+
+ return 0;
#else
- header,
+ return cpystrn(buf, apr_table_get(table, name), buflen);
#endif
- buflen);
- }
- return len;
}
+static int log_header(const ap_errorlog_info *info, const char *arg,
+ char *buf, int buflen)
+{
+ if (info->r)
+ return log_table_entry(info->r->headers_in, arg, buf, buflen);
+
+ return 0;
+}
+
+static int log_note(const ap_errorlog_info *info, const char *arg,
+ char *buf, int buflen)
+{
+ /* XXX: maybe escaping the entry is not necessary for notes? */
+ if (info->r)
+ return log_table_entry(info->r->notes, arg, buf, buflen);
+ return 0;
+}
+
+static int log_env_var(const ap_errorlog_info *info, const char *arg,
+ char *buf, int buflen)
+{
+ if (info->r)
+ return log_table_entry(info->r->subprocess_env, arg, buf, buflen);
+ return 0;
+}
AP_DECLARE(void) ap_register_builtin_errorlog_handlers(apr_pool_t *p)
{
ap_register_errorlog_handler(p, "a", log_remote_address, 0);
ap_register_errorlog_handler(p, "A", log_local_address, 0);
+ ap_register_errorlog_handler(p, "e", log_env_var, 0);
ap_register_errorlog_handler(p, "E", log_apr_status, 0);
ap_register_errorlog_handler(p, "F", log_file_line, 0);
ap_register_errorlog_handler(p, "i", log_header, 0);
@@ -775,11 +794,10 @@ AP_DECLARE(void) ap_register_builtin_err
ap_register_errorlog_handler(p, "l", log_loglevel, 0);
ap_register_errorlog_handler(p, "L", log_log_id, 0);
ap_register_errorlog_handler(p, "m", log_module_name, 0);
+ ap_register_errorlog_handler(p, "n", log_note, 0);
ap_register_errorlog_handler(p, "P", log_pid, 0);
ap_register_errorlog_handler(p, "t", log_ctime, 0);
ap_register_errorlog_handler(p, "T", log_tid, 0);
-
- /* XXX: TODO: envvars, notes */
}
static void add_log_id(const conn_rec *c, const request_rec *r)