diff options
Diffstat (limited to 'modules/loggers')
| -rw-r--r-- | modules/loggers/mod_log_config.c | 22 | ||||
| -rw-r--r-- | modules/loggers/mod_log_forensic.c | 4 | ||||
| -rw-r--r-- | modules/loggers/mod_logio.c | 11 |
3 files changed, 32 insertions, 5 deletions
diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index 72bf5018..cd468be1 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -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 @@ -633,8 +635,22 @@ static const char *log_virtual_host(request_rec *r, char *a) 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 diff --git a/modules/loggers/mod_log_forensic.c b/modules/loggers/mod_log_forensic.c index 3fad35a7..f44f0b46 100644 --- a/modules/loggers/mod_log_forensic.c +++ b/modules/loggers/mod_log_forensic.c @@ -195,8 +195,8 @@ static int log_before(request_rec *r) if (!(id = apr_table_get(r->subprocess_env, "UNIQUE_ID"))) { /* we make the assumption that we can't go through all the PIDs in under 1 second */ - id = apr_psprintf(r->pool, "%x:%lx:%x", getpid(), time(NULL), - apr_atomic_inc32(&next_id)); + id = apr_psprintf(r->pool, "%" APR_PID_T_FMT ":%lx:%x", getpid(), + time(NULL), apr_atomic_inc32(&next_id)); } ap_set_module_config(r->request_config, &log_forensic_module, (char *)id); diff --git a/modules/loggers/mod_logio.c b/modules/loggers/mod_logio.c index 91db4f65..bc4d416c 100644 --- a/modules/loggers/mod_logio.c +++ b/modules/loggers/mod_logio.c @@ -66,6 +66,16 @@ static void ap_logio_add_bytes_out(conn_rec *c, apr_off_t bytes){ } /* + * Optional function for modules to adjust bytes_in + */ + +static void ap_logio_add_bytes_in(conn_rec *c, apr_off_t bytes){ + logio_config_t *cf = ap_get_module_config(c->conn_config, &logio_module); + + cf->bytes_in += bytes; +} + +/* * Format items... */ @@ -178,6 +188,7 @@ static void register_hooks(apr_pool_t *p) AP_FTYPE_NETWORK - 1); APR_REGISTER_OPTIONAL_FN(ap_logio_add_bytes_out); + APR_REGISTER_OPTIONAL_FN(ap_logio_add_bytes_in); } module AP_MODULE_DECLARE_DATA logio_module = |
