[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-httpd-dev
Subject:    [PATCH 1/3] mod_log_config: add creating tag to log_format_item
From:       Thomas Meyer <thomas () m3y3r ! de>
Date:       2023-03-24 21:54:09
Message-ID: 20230324215410.14751-2-thomas () m3y3r ! de
[Download RAW message or body]

Preprartional change for upcoming JSON support
---
 modules/loggers/mod_log_config.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c
index 5d5b73a1f5..6934a8691c 100644
--- a/modules/loggers/mod_log_config.c
+++ b/modules/loggers/mod_log_config.c
@@ -285,6 +285,7 @@ typedef struct {
  */
 
 typedef struct {
+    char *tag; /* tag that did create this lfi */
     ap_log_handler_fn_t *func;
     char *arg;
     int condition_sense;
@@ -884,6 +885,7 @@ static char *parse_log_misc_string(apr_pool_t *p, log_format_item *it,
     const char *s;
     char *d;
 
+    it->tag = NULL;
     it->func = constant_item;
     it->conditions = NULL;
 
@@ -1014,22 +1016,24 @@ static char *parse_log_item(apr_pool_t *p, log_format_item *it, const char **sa)
 
         default:
             /* check for '^' + two character format first */
-            if (*s == '^' && *(s+1) && *(s+2)) { 
+            if (*s == '^' && *(s+1) && *(s+2)) {
                 handler = (ap_log_handler *)apr_hash_get(log_hash, s, 3); 
-                if (handler) { 
+                if (handler) {
+                   it->tag=apr_pstrmemdup(p, s, 3);
                    s += 3;
                 }
             }
             if (!handler) {  
-                handler = (ap_log_handler *)apr_hash_get(log_hash, s++, 1);  
-            }
-            if (!handler) {
-                char dummy[2];
-
-                dummy[0] = s[-1];
-                dummy[1] = '\0';
-                return apr_pstrcat(p, "Unrecognized LogFormat directive %",
-                               dummy, NULL);
+                handler = (ap_log_handler *)apr_hash_get(log_hash, s++, 1);
+                if (!handler) {
+                    char dummy[2];
+
+                    dummy[0] = s[-1];
+                    dummy[1] = '\0';
+                    return apr_pstrcat(p, "Unrecognized LogFormat directive %",
+                                   dummy, NULL);
+                }
+                it->tag=apr_pstrmemdup(p, s, 1);
             }
             it->func = handler->func;
             if (it->want_orig == -1) {
-- 
2.20.1

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic