From: Jeff Trawick Date: Fri, 18 Apr 2003 19:40:11 +0000 (+0000) Subject: change the way that thread id is specified in the log format since X-Git-Tag: pre_ajp_proxy~1824 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f96aba98f9dc5777c7ba059bac46bd3db6bc4207;p=apache change the way that thread id is specified in the log format since the previous implementation used a format string already taken by mod_logio now, an optional %P format is used instead thanks to Andre' Malo for pointing out that I chose a format string already used by mod_logio! git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@99442 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index fbffb8627d..38e182aabb 100644 --- a/CHANGES +++ b/CHANGES @@ -3,7 +3,7 @@ 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] + processing the request via new %P formats. [Jeff Trawick] *) Fix a problem that caused httpd to linked with incorrect flags on some platforms when mod_so was enabled by default, breaking diff --git a/docs/manual/mod/mod_log_config.html.en b/docs/manual/mod/mod_log_config.html.en index 62624559e2..c8685fc95f 100644 --- a/docs/manual/mod/mod_log_config.html.en +++ b/docs/manual/mod/mod_log_config.html.en @@ -97,27 +97,29 @@ Remote host %...H The request protocol -%...I - The thread id if APR supports threads, otherwise 0 -%...{Foobar}i +%...{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. +%...{format}P + The process ID and or thread id of the child that serviced the + request. Valid formats are pid, tid, + and pid/tid. %...q The query string (prepended with a ? if a query string exists, otherwise an empty string) diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index 846f6c0041..49ff38dbb3 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -83,9 +83,6 @@ %...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. @@ -113,6 +110,11 @@ %...P The process ID of the child that serviced the request. + %...{format}P + The process ID and or thread id of the child that serviced the + request. Valid formats are pid, tid, + and pid/tid. + %...q The query string (prepended with a ? if a query string exists, otherwise an empty string) diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index 9b4627a801..85aae5a09e 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -613,20 +613,28 @@ static const char *log_server_name(request_rec *r, char *a) return ap_escape_logitem(r->pool, ap_get_server_name(r)); } -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) +static const char *log_pid_tid(request_rec *r, char *a) { + if (*a == '\0' || !strcmp(a, "pid")) { + return apr_psprintf(r->pool, "%ld", (long)getpid()); + } + else { #if APR_HAS_THREADS - apr_os_thread_t tid = apr_os_thread_current(); - - return apr_psprintf(r->pool, "%pT", &tid); + apr_os_thread_t tid = apr_os_thread_current(); #else - return "0"; + int tid = 0; /* APR will format "0" anyway but an arg is needed */ #endif + + if (!strcmp(a, "pid/tid")) { + return apr_psprintf(r->pool, "%ld/%pT", (long)getpid(), &tid); + } + else if (!strcmp(a, "tid")) { + return apr_psprintf(r->pool, "%pT", &tid); + } + else { /* bogus string */ + return a; + } + } } static const char *log_connection_status(request_rec *r, char *a) @@ -1393,8 +1401,7 @@ static int log_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) log_pfn_register(p, "V", log_server_name, 0); 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, "P", log_pid_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);