Skip to content

Commit

Permalink
Merge pull request #252 from Mixaster995/feature/log-level
Browse files Browse the repository at this point in the history
Added config option for log level
  • Loading branch information
denis-tingaikin authored Oct 12, 2021
2 parents ec2a6fb + be63d74 commit 6c44973
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters-settings:
threshold: 150
funlen:
Lines: 180
Statements: 75
Statements: 80
goconst:
min-len: 2
min-occurrences: 2
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Config struct {
Labels map[string]string `default:"" desc:"Endpoint labels"`
CidrPrefix string `default:"169.254.0.0/16" desc:"CIDR Prefix to assign IPs from" split_words:"true"`
RegisterService bool `default:"true" desc:"if true then registers network service on startup" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
}

// Process prints and processes env to config
Expand Down Expand Up @@ -131,6 +132,12 @@ func main() {
logrus.Fatal(err.Error())
}

l, err := logrus.ParseLevel(config.LogLevel)
if err != nil {
logrus.Fatalf("invalid log level %s", config.LogLevel)
}
logrus.SetLevel(l)

log.FromContext(ctx).Infof("Config: %#v", config)

// ********************************************************************************
Expand Down

0 comments on commit 6c44973

Please sign in to comment.