From a89325c41b0063446154459772949291d8086367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 30 Apr 2021 20:58:14 +0200 Subject: [PATCH] chore: expose logger and use it, simplifying initialisation --- cli/config/config.go | 5 +++-- cli/config/config_test.go | 4 ++-- e2e/_suites/helm/helm_charts_test.go | 2 +- e2e/_suites/kubernetes-autodiscover/autodiscover_test.go | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cli/config/config.go b/cli/config/config.go index a77d574251..e063410452 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -124,7 +124,7 @@ func Init() { return } - configureLogger() + ConfigureLogger() binaries := []string{ "docker", @@ -246,7 +246,8 @@ func checkConfigDirs(workspace string) { }).Trace("'op' workdirs created.") } -func configureLogger() { +// ConfigureLogger sets the log for the application +func ConfigureLogger() { includeTimestamp := os.Getenv("OP_LOG_INCLUDE_TIMESTAMP") fullTimestamp := (strings.ToUpper(includeTimestamp) == "TRUE") diff --git a/cli/config/config_test.go b/cli/config/config_test.go index ecb8db5e65..69786a10f3 100644 --- a/cli/config/config_test.go +++ b/cli/config/config_test.go @@ -42,7 +42,7 @@ func TestConfigureLoggerWithTimestamps(t *testing.T) { os.Setenv("OP_LOG_INCLUDE_TIMESTAMP", "true") defer cleanUpEnv() - configureLogger() + ConfigureLogger() logger := logrus.New() @@ -104,7 +104,7 @@ func checkLoggerWithLogLevel(t *testing.T, level string) { level = "INFO" } - configureLogger() + ConfigureLogger() logLevel := logrus.GetLevel() diff --git a/e2e/_suites/helm/helm_charts_test.go b/e2e/_suites/helm/helm_charts_test.go index b0d81b35c6..3b75f146d9 100644 --- a/e2e/_suites/helm/helm_charts_test.go +++ b/e2e/_suites/helm/helm_charts_test.go @@ -63,7 +63,7 @@ var tx *apm.Transaction var stepSpan *apm.Span func setupSuite() { - config.Init() + config.ConfigureLogger() developerMode = shell.GetEnvBool("DEVELOPER_MODE") if developerMode { diff --git a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go index b8e8cbab7f..b371b16d0e 100644 --- a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go +++ b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go @@ -469,7 +469,7 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) { ctx.BeforeSuite(func() { // init logger - config.Init() + config.ConfigureLogger() err := cluster.Initialize(suiteContext, "testdata/kind.yml") if err != nil {