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
5 changes: 3 additions & 2 deletions command/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (

// Config stores the system configuration.
type Config struct {
Debug bool `envconfig:"DRONE_DEBUG"`
Trace bool `envconfig:"DRONE_TRACE"`
Debug bool `envconfig:"DRONE_DEBUG"`
Trace bool `envconfig:"DRONE_TRACE"`
LogJSON bool `envconfig:"DRONE_LOG_JSON"`

Client struct {
Address string `ignored:"true"`
Expand Down
3 changes: 3 additions & 0 deletions command/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ func setupLogger(config Config) {
if config.Trace {
logrus.SetLevel(logrus.TraceLevel)
}
if config.LogJSON {
logrus.SetFormatter(&logrus.JSONFormatter{})
}
}

// Register the daemon command.
Expand Down
8 changes: 8 additions & 0 deletions command/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type execCommand struct {
Procs int64
Debug bool
Trace bool
LogJSON bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest backing out the changes to this file. The exec command is used for local development and testing only and we would never need / use json logging here.

Dump bool
PublicKey string
PrivateKey string
Expand Down Expand Up @@ -224,6 +225,10 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
if c.Trace {
logrus.SetLevel(logrus.TraceLevel)
}
if c.LogJSON {
logrus.SetFormatter(&logrus.JSONFormatter{})
}

logger.Default = logger.Logrus(
logrus.NewEntry(
logrus.StandardLogger(),
Expand Down Expand Up @@ -357,6 +362,9 @@ func registerExec(app *kingpin.Application) {
cmd.Flag("trace", "enable trace logging").
BoolVar(&c.Trace)

cmd.Flag("log-json", "enable JSON structured logging").
BoolVar(&c.LogJSON)

cmd.Flag("dump", "dump the pipeline state to stdout").
BoolVar(&c.Dump)

Expand Down