From 5d79cd7197665db2a85f9762e606cac1d7db21a0 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Fri, 18 Apr 2003 10:44:11 +0000 Subject: [PATCH] mod_log_config: Add the ability to log the id of the thread processing the request (%I). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@99439 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 ++ docs/manual/mod/mod_log_config.html.en | 42 ++++++++++++++------------ docs/manual/mod/mod_log_config.xml | 3 ++ modules/loggers/mod_log_config.c | 14 +++++++++ 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 03a8eaed47..fbffb8627d 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) mod_log_config: Add the ability to log the id of the thread + processing the request (%I). [Jeff Trawick] + *) Fix a problem that caused httpd to linked with incorrect flags on some platforms when mod_so was enabled by default, breaking DSOs on AIX. PR 19012 [Jeff Trawick] diff --git a/docs/manual/mod/mod_log_config.html.en b/docs/manual/mod/mod_log_config.html.en index 1ce35db113..62624559e2 100644 --- a/docs/manual/mod/mod_log_config.html.en +++ b/docs/manual/mod/mod_log_config.html.en @@ -97,53 +97,55 @@ Remote host %...H The request protocol -%...{Foobar}i +%...I + The thread id if APR supports threads, otherwise 0 +%...{Foobar}i The contents of Foobar: header line(s) in the request sent to the server. -%...l +%...l Remote logname (from identd, if supplied). This will return a dash unless mod_ident is present and IdentityCheck is set On. -%...m +%...m The request method -%...{Foobar}n +%...{Foobar}n The contents of note Foobar from another module. -%...{Foobar}o +%...{Foobar}o The contents of Foobar: header line(s) in the reply. -%...p +%...p The canonical port of the server serving the request -%...P +%...P The process ID of the child that serviced the request. -%...q +%...q The query string (prepended with a ? if a query string exists, otherwise an empty string) -%...r +%...r First line of request -%...s +%...s Status. For requests that got internally redirected, this is the status of the *original* request --- %...>s for the last. -%...t +%...t Time, in common log format time format (standard english format) -%...{format}t +%...{format}t The time, in the form given by format, which should be in strftime(3) format. (potentially localized) -%...T +%...T The time taken to serve the request, in seconds. -%...u +%...u Remote user (from auth; may be bogus if return status (%s) is 401) -%...U +%...U The URL path requested, not including any query string. -%...v +%...v The canonical ServerName of the server serving the request. -%...V +%...V The server name according to the UseCanonicalName setting. -%...X +%...X Connection status when response is completed: @@ -160,10 +162,10 @@

(This directive was %...c in late versions of Apache 1.3, but this conflicted with the historical ssl %...{var}c syntax.)

- + - +
%...I
%...I Bytes received, including request and headers, cannot be zero. You need to enable mod_logio to use this.
%...O
%...O Bytes sent, including headers, cannot be zero. You need to enable mod_logio to use this.
diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index 55a0a573c4..846f6c0041 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -83,6 +83,9 @@ %...H The request protocol + %...I + The thread id if APR supports threads, otherwise 0 + %...{Foobar}i The contents of Foobar: header line(s) in the request sent to the server. diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index 0e28ac5f99..9b4627a801 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -134,6 +134,8 @@ * %...{Foobar}o: The contents of Foobar: header line(s) in the reply. * %...p: the port the request was served to * %...P: the process ID of the child that serviced the request. + * %...I: the thread ID of the thread that serviced the request (or + * 0 if APR doesn't support threads) * %...r: first line of request * %...s: status. For requests that got internally redirected, this * is status of the *original* request --- %...>s for the last. @@ -616,6 +618,17 @@ static const char *log_child_pid(request_rec *r, char *a) return apr_psprintf(r->pool, "%ld", (long) getpid()); } +static const char *log_tid(request_rec *r, char *a) +{ +#if APR_HAS_THREADS + apr_os_thread_t tid = apr_os_thread_current(); + + return apr_psprintf(r->pool, "%pT", &tid); +#else + return "0"; +#endif +} + static const char *log_connection_status(request_rec *r, char *a) { if (r->connection->aborted) @@ -1381,6 +1394,7 @@ static int log_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) log_pfn_register(p, "v", log_virtual_host, 0); log_pfn_register(p, "p", log_server_port, 0); log_pfn_register(p, "P", log_child_pid, 0); + log_pfn_register(p, "I", log_tid, 0); log_pfn_register(p, "H", log_request_protocol, 0); log_pfn_register(p, "m", log_request_method, 0); log_pfn_register(p, "q", log_request_query, 0); -- 2.50.1