summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_router_access_log.c
diff options
context:
space:
mode:
authorDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
committerDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
commitd76761901c4084bcdbc5a449e9bbb47d56b7093c (patch)
treeb4b7b4e3d588b73a2adcc0094cab466d9194c679 /src/nxt_router_access_log.c
parentc43629880472bba8d389dfb0b7ae6d883b0ba499 (diff)
parent088117008c9e8f397a58cc8d8070ce047beff12f (diff)
downloadunit-1.32.0-1.tar.gz
unit-1.32.0-1.tar.bz2
Merge tag '1.32.0' into branches/packaging1.32.0-1
Unit 1.32.0 release.
Diffstat (limited to 'src/nxt_router_access_log.c')
-rw-r--r--src/nxt_router_access_log.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nxt_router_access_log.c b/src/nxt_router_access_log.c
index ccbddb96..7fc59972 100644
--- a/src/nxt_router_access_log.c
+++ b/src/nxt_router_access_log.c
@@ -13,6 +13,7 @@
typedef struct {
nxt_str_t path;
nxt_str_t format;
+ nxt_conf_value_t *expr;
} nxt_router_access_log_conf_t;
@@ -53,6 +54,12 @@ static nxt_conf_map_t nxt_router_access_log_conf[] = {
NXT_CONF_MAP_STR,
offsetof(nxt_router_access_log_conf_t, format),
},
+
+ {
+ nxt_string("if"),
+ NXT_CONF_MAP_PTR,
+ offsetof(nxt_router_access_log_conf_t, expr),
+ },
};
@@ -72,6 +79,8 @@ nxt_router_access_log_create(nxt_task_t *task, nxt_router_conf_t *rtcf,
"[$time_local] \"$request_line\" $status $body_bytes_sent "
"\"$header_referer\" \"$header_user_agent\"");
+ nxt_memzero(&alcf, sizeof(nxt_router_access_log_conf_t));
+
alcf.format = log_format_str;
if (nxt_conf_type(value) == NXT_CONF_STRING) {
@@ -133,6 +142,22 @@ nxt_router_access_log_create(nxt_task_t *task, nxt_router_conf_t *rtcf,
rtcf->access_log = access_log;
rtcf->log_format = format;
+ if (alcf.expr != NULL) {
+ nxt_conf_get_string(alcf.expr, &str);
+
+ if (str.length > 0 && str.start[0] == '!') {
+ rtcf->log_negate = 1;
+
+ str.start++;
+ str.length--;
+ }
+
+ rtcf->log_expr = nxt_tstr_compile(rtcf->tstr_state, &str, 0);
+ if (nxt_slow_path(rtcf->log_expr == NULL)) {
+ return NXT_ERROR;
+ }
+ }
+
return NXT_OK;
}