Skip to content

Commit 01d5568

Browse files
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
1 parent 1f4a6fa commit 01d5568

File tree

7 files changed

+476
-34
lines changed

7 files changed

+476
-34
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
GO_SEMVER: '~1.21.0'
3434

3535
- go: '1.22'
36-
GO_SEMVER: '~1.22.0'
36+
GO_SEMVER: '~1.22.1'
3737

3838
# Set some variables per OS, usable via ${{ matrix.VAR }}
3939
# OS_LABEL: the VM label from GitHub Actions (see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories)

.github/workflows/cross-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# Set the minimum Go patch version for the given Go minor
3636
# Usable via ${{ matrix.GO_SEMVER }}
3737
- go: '1.22'
38-
GO_SEMVER: '~1.22.0'
38+
GO_SEMVER: '~1.22.1'
3939

4040
runs-on: ubuntu-latest
4141
continue-on-error: true

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- uses: actions/checkout@v4
4444
- uses: actions/setup-go@v5
4545
with:
46-
go-version: '~1.22.0'
46+
go-version: '~1.22.1'
4747
check-latest: true
4848

4949
- name: golangci-lint
@@ -66,5 +66,5 @@ jobs:
6666
- name: govulncheck
6767
uses: golang/govulncheck-action@v1
6868
with:
69-
go-version-input: '~1.22.0'
69+
go-version-input: '~1.22.1'
7070
check-latest: true
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
log {
3+
format append {
4+
wrap json
5+
fields {
6+
wrap "foo"
7+
}
8+
env {env.EXAMPLE}
9+
int 1
10+
float 1.1
11+
bool true
12+
string "string"
13+
}
14+
}
15+
}
16+
17+
:80 {
18+
respond "Hello, World!"
19+
}
20+
----------
21+
{
22+
"logging": {
23+
"logs": {
24+
"default": {
25+
"encoder": {
26+
"fields": {
27+
"bool": true,
28+
"env": "{env.EXAMPLE}",
29+
"float": 1.1,
30+
"int": 1,
31+
"string": "string",
32+
"wrap": "foo"
33+
},
34+
"format": "append",
35+
"wrap": {
36+
"format": "json"
37+
}
38+
}
39+
}
40+
}
41+
},
42+
"apps": {
43+
"http": {
44+
"servers": {
45+
"srv0": {
46+
"listen": [
47+
":80"
48+
],
49+
"routes": [
50+
{
51+
"handle": [
52+
{
53+
"body": "Hello, World!",
54+
"handler": "static_response"
55+
}
56+
]
57+
}
58+
]
59+
}
60+
}
61+
}
62+
}
63+
}

caddytest/integration/caddyfile_adapt/log_filters.caddyfiletest

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ log {
44
output stdout
55
format filter {
66
wrap console
7+
8+
# long form, with "fields" wrapper
79
fields {
810
uri query {
911
replace foo REDACTED
1012
delete bar
1113
hash baz
1214
}
13-
request>headers>Authorization replace REDACTED
14-
request>headers>Server delete
15-
request>headers>Cookie cookie {
16-
replace foo REDACTED
17-
delete bar
18-
hash baz
19-
}
20-
request>remote_ip ip_mask {
21-
ipv4 24
22-
ipv6 32
23-
}
24-
request>client_ip ip_mask 16 32
25-
request>headers>Regexp regexp secret REDACTED
26-
request>headers>Hash hash
2715
}
16+
17+
# short form, flatter structure
18+
request>headers>Authorization replace REDACTED
19+
request>headers>Server delete
20+
request>headers>Cookie cookie {
21+
replace foo REDACTED
22+
delete bar
23+
hash baz
24+
}
25+
request>remote_ip ip_mask {
26+
ipv4 24
27+
ipv6 32
28+
}
29+
request>client_ip ip_mask 16 32
30+
request>headers>Regexp regexp secret REDACTED
31+
request>headers>Hash hash
2832
}
2933
}
3034
----------

0 commit comments

Comments
 (0)