You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2022/05/27 12:20:37 UTC
[tomcat-connectors] branch main updated: Provide jk_request_log adding request id to mod_jk error log lines
This is an automated email from the ASF dual-hosted git repository.
rjung pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-connectors.git
The following commit(s) were added to refs/heads/main by this push:
new edb52b89f Provide jk_request_log adding request id to mod_jk error log lines
edb52b89f is described below
commit edb52b89f78606439df1d0013463dbae55b46980
Author: Rainer Jung <ra...@kippdata.de>
AuthorDate: Fri May 27 14:20:21 2022 +0200
Provide jk_request_log adding request id to mod_jk error log lines
---
native/common/jk_util.c | 28 +++++++++++++++++++++++++++-
native/common/jk_util.h | 8 +++++---
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/native/common/jk_util.c b/native/common/jk_util.c
index 7149fc68a..5df4f2a1d 100644
--- a/native/common/jk_util.c
+++ b/native/common/jk_util.c
@@ -694,7 +694,7 @@ int jk_close_file_logger(jk_logger_t **l)
return JK_FALSE;
}
-int jk_log(jk_logger_t *l,
+int jk_request_log(jk_ws_service_t *s, jk_logger_t *l,
const char *file, int line, const char *funcname, int level,
const char *fmt, ...)
{
@@ -726,6 +726,32 @@ int jk_log(jk_logger_t *l,
used = set_time_str(buf, usable_size, l);
if (line) { /* line==0 only used for request log item */
+ /* Log [requestid] for all levels except REQUEST.
+ */
+ const char *request_id;
+ if (s == NULL) {
+ request_id = "-";
+ rc = 1;
+ } else if (s->request_id == NULL) {
+ request_id = "NO-ID";
+ rc = 1;
+ } else {
+ request_id = s->request_id;
+ rc = (int)strlen(request_id);
+ }
+ if (usable_size - used >= rc + 3) {
+ strncpy(buf + used, "[", 1);
+ used += 1;
+ strncpy(buf + used, request_id, rc);
+ used += rc;
+ strncpy(buf + used, "] ", 2);
+ used += 2;
+ } else {
+ strcpy(buf, "Logging failed in request_id formatting");
+ l->log(l, level, (int)strlen(buf), buf);
+ return 0;
+ }
+
/* Log [pid:threadid] for all levels except REQUEST.
* This information helps to correlate lines from different logs.
* Performance is no issue, because with production log levels
diff --git a/native/common/jk_util.h b/native/common/jk_util.h
index db15775c2..b8e15500d 100644
--- a/native/common/jk_util.h
+++ b/native/common/jk_util.h
@@ -53,9 +53,11 @@ int jk_attach_file_logger(jk_logger_t **l, int fd, int level);
int jk_close_file_logger(jk_logger_t **l);
-int jk_log(jk_logger_t *l,
- const char *file, int line, const char *funcname, int level,
- const char *fmt, ...);
+int jk_request_log(jk_ws_service_t *s, jk_logger_t *l,
+ const char *file, int line, const char *funcname, int level,
+ const char *fmt, ...);
+
+#define jk_log(...) jk_request_log(NULL, __VA_ARGS__)
int jk_check_attribute_length(const char *name, const char *value,
jk_logger_t *l);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org