File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ import (
1414
1515// Config stores the system configuration.
1616type Config struct {
17- Debug bool `envconfig:"DRONE_DEBUG"`
18- Trace bool `envconfig:"DRONE_TRACE"`
17+ Debug bool `envconfig:"DRONE_DEBUG"`
18+ Trace bool `envconfig:"DRONE_TRACE"`
19+ LogJSON bool `envconfig:"DRONE_LOG_JSON"`
1920
2021 Client struct {
2122 Address string `ignored:"true"`
Original file line number Diff line number Diff line change @@ -275,7 +275,9 @@ func setupLogger(config Config) {
275275 if config .Trace {
276276 logrus .SetLevel (logrus .TraceLevel )
277277 }
278- logrus .SetFormatter (& logrus.JSONFormatter {})
278+ if config .LogJSON {
279+ logrus .SetFormatter (& logrus.JSONFormatter {})
280+ }
279281}
280282
281283// Register the daemon command.
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ type execCommand struct {
5656 Procs int64
5757 Debug bool
5858 Trace bool
59+ LogJSON bool
5960 Dump bool
6061 PublicKey string
6162 PrivateKey string
@@ -224,7 +225,9 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
224225 if c .Trace {
225226 logrus .SetLevel (logrus .TraceLevel )
226227 }
227- logrus .SetFormatter (& logrus.JSONFormatter {})
228+ if c .LogJSON {
229+ logrus .SetFormatter (& logrus.JSONFormatter {})
230+ }
228231
229232 logger .Default = logger .Logrus (
230233 logrus .NewEntry (
@@ -359,6 +362,9 @@ func registerExec(app *kingpin.Application) {
359362 cmd .Flag ("trace" , "enable trace logging" ).
360363 BoolVar (& c .Trace )
361364
365+ cmd .Flag ("log-json" , "enable JSON structured logging" ).
366+ BoolVar (& c .LogJSON )
367+
362368 cmd .Flag ("dump" , "dump the pipeline state to stdout" ).
363369 BoolVar (& c .Dump )
364370
You can’t perform that action at this time.
0 commit comments