Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/buildkitd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type SystemConfig struct {

type LogConfig struct {
Format string `toml:"format"`
Level string `toml:"level"`
}

type GRPCConfig struct {
Expand Down
17 changes: 17 additions & 0 deletions cmd/buildkitd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ func main() {
Usage: "log formatter: json or text",
Value: "text",
},
cli.StringFlag{
Name: "log-level",
Usage: "set the log level",
Value: "info",
EnvVar: "BUILDKITD_LOG_LEVEL",
},
cli.StringFlag{
Name: "group",
Usage: groupUsageStr,
Expand Down Expand Up @@ -273,6 +279,14 @@ func main() {
logrus.SetLevel(logrus.TraceLevel)
}

if cfg.Log.Level != "" {
level, err := logrus.ParseLevel(cfg.Log.Level)
if err != nil {
return errors.Wrap(err, "unsupported log level")
}
logrus.SetLevel(level)
}

if sc := cfg.System; sc != nil {
if v := sc.PlatformsCacheMaxAge; v != nil {
archutil.CacheMaxAge = v.Duration
Expand Down Expand Up @@ -598,6 +612,9 @@ func applyMainFlags(c *cli.Context, cfg *config.Config) error {
if c.IsSet("log-format") {
cfg.Log.Format = c.String("log-format")
}
if c.IsSet("log-level") {
cfg.Log.Level = c.String("log-level")
}
if c.IsSet("addr") || len(cfg.GRPC.Address) == 0 {
cfg.GRPC.Address = c.StringSlice("addr")
}
Expand Down
Loading