You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2007/09/26 03:45:18 UTC
svn commit: r579425 - in /httpd/httpd/trunk: CHANGES
docs/manual/mod/mod_log_config.xml modules/loggers/mod_log_config.c
Author: trawick
Date: Tue Sep 25 18:45:16 2007
New Revision: 579425
URL: http://svn.apache.org/viewvc?rev=579425&view=rev
Log:
mod_log_config: Add format options for %p so that the actual local
or remote port can be logged.
PR: 43415
Submitted by: Adam Hasselbalch Hansen <ah...@one.com>
Extensively commented on and/or modified by Ruediger Pluem and Jeff Trawick
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/docs/manual/mod/mod_log_config.xml
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=579425&r1=579424&r2=579425&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Sep 25 18:45:16 2007
@@ -2,6 +2,10 @@
Changes with Apache 2.3.0
[ When backported to 2.2.x, remove entry from this file ]
+ *) mod_log_config: Add format options for %p so that the actual local
+ or remote port can be logged. PR 43415. [Adam Hasselbalch Hansen
+ <ah...@one.com>, Ruediger Pluem, Jeff Trawick]
+
*) scoreboard: improve error message on apr_shm_create failure
PR 40037 [Nick Kew]
Modified: httpd/httpd/trunk/docs/manual/mod/mod_log_config.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_log_config.xml?rev=579425&r1=579424&r2=579425&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_log_config.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_log_config.xml Tue Sep 25 18:45:16 2007
@@ -127,6 +127,12 @@
<tr><td><code>%p</code></td>
<td>The canonical port of the server serving the request</td></tr>
+ <tr><td><code>%{<var>format</var>}p</code></td>
+ <td>The canonical port of the server serving the request or the
+ server's actual port or the client's actual port. Valid formats
+ are <code>canonical</code>, <code>local</code>, or <code>remote</code>.
+ </td></tr>
+
<tr><td><code>%P</code></td>
<td>The process ID of the child that serviced the request.</td></tr>
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=579425&r1=579424&r2=579425&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_log_config.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_log_config.c Tue Sep 25 18:45:16 2007
@@ -90,7 +90,9 @@
* %...l: remote logname (from identd, if supplied)
* %...{Foobar}n: The contents of note "Foobar" from another module.
* %...{Foobar}o: The contents of Foobar: header line(s) in the reply.
- * %...p: the port the request was served to
+ * %...p: the canonical port for the server
+ * %...{format}p: the canonical port for the server, or the actual local
+ * or remote port
* %...P: the process ID of the child that serviced the request.
* %...{format}P: the process ID or thread ID of the child/thread that
* serviced the request
@@ -628,8 +630,22 @@
static const char *log_server_port(request_rec *r, char *a)
{
- return apr_psprintf(r->pool, "%u",
- r->server->port ? r->server->port : ap_default_port(r));
+ apr_port_t port;
+
+ if (*a == '\0' || !strcasecmp(a, "canonical")) {
+ port = r->server->port ? r->server->port : ap_default_port(r);
+ }
+ else if (!strcasecmp(a, "remote")) {
+ port = r->connection->remote_addr->port;
+ }
+ else if (!strcasecmp(a, "local")) {
+ port = r->connection->local_addr->port;
+ }
+ else {
+ /* bogus format */
+ return a;
+ }
+ return apr_itoa(r->pool, (int)port);
}
/* This respects the setting of UseCanonicalName so that