From f9500b2c43b7fa60528eae3b5a0fe9f005438bbd Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Fri, 14 Aug 2020 22:51:49 -0400 Subject: [PATCH] tink-worker should initialize logger level early --- cmd/tink-worker/action.go | 8 ++++++-- cmd/tink-worker/main.go | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/tink-worker/action.go b/cmd/tink-worker/action.go index bd41412a9..014bf884d 100644 --- a/cmd/tink-worker/action.go +++ b/cmd/tink-worker/action.go @@ -276,6 +276,12 @@ func initializeDockerClient() (*client.Client, error) { if err != nil { return nil, errors.Wrap(err, "DOCKER CLIENT") } + + logger.SetFormatter(&logrus.JSONFormatter{}) + return c, nil +} + +func initializeLogger() { level := os.Getenv("WORKER_LOG_LEVEL") if level != "" { switch strings.ToLower(level) { @@ -301,6 +307,4 @@ func initializeDockerClient() (*client.Client, error) { logger.SetLevel(logrus.InfoLevel) logger.Warningln("Variable WORKER_LOG_LEVEL is not set. Default is Info") } - logger.SetFormatter(&logrus.JSONFormatter{}) - return c, nil } diff --git a/cmd/tink-worker/main.go b/cmd/tink-worker/main.go index f7ff568b8..8783926fc 100644 --- a/cmd/tink-worker/main.go +++ b/cmd/tink-worker/main.go @@ -30,6 +30,7 @@ var ( ) func main() { + initializeLogger() logger.Debug("Starting version " + version) setupRetry() if setupErr := client.Setup(); setupErr != nil {