-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging: Implement Caddyfile support for filter encoder #3578
Conversation
Is the
|
Yeah I found it strange, I think it's just Golang's JSON encoder being funky. I don't do anything special here. I asked Matt and he said he's not concerned about it. |
Apparently we could switch to an Encoder instead of json.Marshal if we don't want the HTML escaping:
— https://golang.org/pkg/encoding/json/#Marshal To clarify, however, I'm indifferent about this. It's technically correct as-is. I don't think this will be injected into HTML script tags, so I'm also not worried about that. It's probably fine either way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM so far!
When you have a chance, I'm hoping to do a final pass for 2.2 reviews next week. :) |
ffe2bc2
to
897a56b
Compare
897a56b
to
f641a40
Compare
Okay, this now supports IP filters. I also added support for CIDR in the format that
{
"logging": {
"logs": {
"default": {
"exclude": [
"http.log.access.log0"
]
},
"log0": {
"writer": {
"output": "stdout"
},
"encoder": {
"fields": {
"request\u003eremote_addr": {
"filter": "ip_mask",
"ipv4_cidr": 24,
"ipv6_cidr": "2001:db8::/32"
}
},
"format": "filter",
"wrap": {
"format": "console"
}
},
"include": [
"http.log.access.log0"
]
}
}
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":80"
],
"logs": {
"default_logger_name": "log0"
}
}
}
}
}
} I still need to add a few adapt tests then this should be done. A task for tomorrow. |
f641a40
to
ccdb262
Compare
Okay, this is all done. I got rid of that abstraction I made that allows stuff like I kept the optimization I made of parsing the int into an IP mask at provision time, it's a super tiny optimization but it removes that overhead from every request being logged, so I think it's good to have. Small wins. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kewl, LGTM. Shall we merge this?
Yes 😄 |
A big thank you to @francislavoie for implementing this and @mholt for getting it merged! |
Closes #3694
This is essentially done but lacks tests and proper support for theip_mask
filter.Caddyfile:
Adapted JSON: