-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add support for JSON formatted logs #4044
Conversation
460b516
to
5623955
Compare
a7f6b61
to
1814f85
Compare
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.
Thanks for carrying this @chagui 🎉 Left a couple comments 👍
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.
For buildkitd I wonder if we should have a LogConfig
struct with Format
attr instead of just LogFormat
so we could extend log config in the future such as caller
bool that would add file:line of the caller to log output. I was also thinking of a level
one as well that would be overloaded by Debug
if set.
In TOML config it would look like:
[log]
level = "info"
format = "text"
caller = false
I really like the idea, I will update the code accordingly. |
6fe07a0
to
a878aa8
Compare
cmd/buildkitd/config/config.go
Outdated
@@ -27,6 +27,11 @@ type Config struct { | |||
DNS *DNSConfig `toml:"dns"` | |||
|
|||
History *HistoryConfig `toml:"history"` | |||
|
|||
// LogFormat is the format of the logs. It can be "json" or "text". | |||
Log struct { |
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.
Please avoid nested struct and create a dedicated type LogConfig
like HistoryConfig
.
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.
Done.
Out of curiosity what is the rational for avoiding nested struct?
I saw the Workers
nested struct and thought to do the same because Log
would be a simple one.
Signed-off-by: Guilhem Charles <[email protected]>
PTAL @crazy-max |
Description
This pull-request introduce a configuration option to set the log format to JSON. The option is available both via the config file and CLI arguments.
Solves #3133
How to use it
config file entry
CLIs argument:
buildkitd --log-format json
buildctl --log-format json
Notes
Original work from @moeghanem and @benjamin010095. I forked #3824 and squashed the commits into a single one.
See also: