summaryrefslogtreecommitdiffhomepage
path: root/caddytest
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-03-05 18:24:32 -0500
committerGitHub <[email protected]>2024-03-05 16:24:32 -0700
commit01d5568b20408a7f72fb53095e2e146f0c39672a (patch)
tree858bd2129c48e24cce117a08cc3f711cbb6c15c1 /caddytest
parent1f4a6fa7e7d60bbcd9e29ca35072a76d61cf84c3 (diff)
downloadcaddy-01d5568b20408a7f72fb53095e2e146f0c39672a.tar.gz
caddy-01d5568b20408a7f72fb53095e2e146f0c39672a.zip
logging: Implement `append` encoder, allow flatter filters config (#6069)
* logging: Implement `add` encoder * Allow flatter config structure for `filter` & `add` * Rename to append * govulncheck was unhappy
Diffstat (limited to 'caddytest')
-rw-r--r--caddytest/integration/caddyfile_adapt/log_append_encoder.caddyfiletest63
-rw-r--r--caddytest/integration/caddyfile_adapt/log_filters.caddyfiletest32
2 files changed, 81 insertions, 14 deletions
diff --git a/caddytest/integration/caddyfile_adapt/log_append_encoder.caddyfiletest b/caddytest/integration/caddyfile_adapt/log_append_encoder.caddyfiletest
new file mode 100644
index 000000000..88a6cd6be
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/log_append_encoder.caddyfiletest
@@ -0,0 +1,63 @@
+{
+ log {
+ format append {
+ wrap json
+ fields {
+ wrap "foo"
+ }
+ env {env.EXAMPLE}
+ int 1
+ float 1.1
+ bool true
+ string "string"
+ }
+ }
+}
+
+:80 {
+ respond "Hello, World!"
+}
+----------
+{
+ "logging": {
+ "logs": {
+ "default": {
+ "encoder": {
+ "fields": {
+ "bool": true,
+ "env": "{env.EXAMPLE}",
+ "float": 1.1,
+ "int": 1,
+ "string": "string",
+ "wrap": "foo"
+ },
+ "format": "append",
+ "wrap": {
+ "format": "json"
+ }
+ }
+ }
+ }
+ },
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":80"
+ ],
+ "routes": [
+ {
+ "handle": [
+ {
+ "body": "Hello, World!",
+ "handler": "static_response"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/caddytest/integration/caddyfile_adapt/log_filters.caddyfiletest b/caddytest/integration/caddyfile_adapt/log_filters.caddyfiletest
index 28524a346..1b2fc2e50 100644
--- a/caddytest/integration/caddyfile_adapt/log_filters.caddyfiletest
+++ b/caddytest/integration/caddyfile_adapt/log_filters.caddyfiletest
@@ -4,27 +4,31 @@ log {
output stdout
format filter {
wrap console
+
+ # long form, with "fields" wrapper
fields {
uri query {
replace foo REDACTED
delete bar
hash baz
}
- request>headers>Authorization replace REDACTED
- request>headers>Server delete
- request>headers>Cookie cookie {
- replace foo REDACTED
- delete bar
- hash baz
- }
- request>remote_ip ip_mask {
- ipv4 24
- ipv6 32
- }
- request>client_ip ip_mask 16 32
- request>headers>Regexp regexp secret REDACTED
- request>headers>Hash hash
}
+
+ # short form, flatter structure
+ request>headers>Authorization replace REDACTED
+ request>headers>Server delete
+ request>headers>Cookie cookie {
+ replace foo REDACTED
+ delete bar
+ hash baz
+ }
+ request>remote_ip ip_mask {
+ ipv4 24
+ ipv6 32
+ }
+ request>client_ip ip_mask 16 32
+ request>headers>Regexp regexp secret REDACTED
+ request>headers>Hash hash
}
}
----------