Skip to content
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

Do not print log level on CLI #2638

Merged
merged 4 commits into from
Oct 24, 2023
Merged
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
2 changes: 1 addition & 1 deletion cli/common/zerologger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import (
)

func SetupGlobalLogger(c *cli.Context) error {
common.SetupGlobalLogger(c)
common.SetupGlobalLogger(c, false)
return nil
}
2 changes: 1 addition & 1 deletion cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (
)

func run(c *cli.Context) error {
common.SetupGlobalLogger(c)
common.SetupGlobalLogger(c, true)

agentConfigPath := c.String("agent-config")
hostname := c.String("hostname")
Expand Down
5 changes: 1 addition & 4 deletions cmd/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func newApp() *cli.App {
app.Usage = "command line utility"
app.EnableBashCompletion = true
app.Flags = common.GlobalFlags
app.Before = common.SetupGlobalLogger
xoxys marked this conversation as resolved.
Show resolved Hide resolved
app.Commands = []*cli.Command{
pipeline.Command,
log.Command,
Expand All @@ -56,9 +57,5 @@ func newApp() *cli.App {
cron.Command,
}

for _, command := range app.Commands {
command.Before = common.SetupGlobalLogger
}

return app
}
6 changes: 4 additions & 2 deletions cmd/common/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var GlobalLoggerFlags = []cli.Flag{
},
}

func SetupGlobalLogger(c *cli.Context) {
func SetupGlobalLogger(c *cli.Context, printLvl bool) {
logLevel := c.String("log-level")
pretty := c.Bool("pretty")
noColor := c.Bool("nocolor")
Expand Down Expand Up @@ -96,5 +96,7 @@ func SetupGlobalLogger(c *cli.Context) {
log.Logger = log.With().Caller().Logger()
}

log.Info().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())
if printLvl {
log.Info().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())
}
}
2 changes: 1 addition & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import (
)

func run(c *cli.Context) error {
common.SetupGlobalLogger(c)
common.SetupGlobalLogger(c, true)

// set gin mode based on log level
if zerolog.GlobalLevel() > zerolog.DebugLevel {
Expand Down