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

Allow setting any log level #284

Merged
merged 2 commits into from
Jan 9, 2024
Merged
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
12 changes: 10 additions & 2 deletions app/cmd/goaws.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
func main() {
var filename string
var debug bool
var loglevel string
flag.StringVar(&filename, "config", "", "config file location + name")
flag.BoolVar(&debug, "debug", false, "debug log level (default Warning)")
flag.BoolVar(&debug, "debug", false, "set debug log level")
flag.StringVar(&loglevel, "loglevel", "info", "log level (default info)")
flag.Parse()

log.SetFormatter(&log.JSONFormatter{})
Expand All @@ -28,7 +30,13 @@ func main() {
if debug {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
level, err := log.ParseLevel(loglevel)
if err != nil {
log.SetLevel(log.InfoLevel)
log.Warnf("Failed to parse loglevel %v, defaulting to info", loglevel)
} else {
log.SetLevel(level)
}
}

env := "Local"
Expand Down
Loading