Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
chore: expose logger and use it, simplifying initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Apr 30, 2021
1 parent 30b5d8d commit a89325c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func Init() {
return
}

configureLogger()
ConfigureLogger()

binaries := []string{
"docker",
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions cli/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestConfigureLoggerWithTimestamps(t *testing.T) {
os.Setenv("OP_LOG_INCLUDE_TIMESTAMP", "true")
defer cleanUpEnv()

configureLogger()
ConfigureLogger()

logger := logrus.New()

Expand Down Expand Up @@ -104,7 +104,7 @@ func checkLoggerWithLogLevel(t *testing.T, level string) {
level = "INFO"
}

configureLogger()
ConfigureLogger()

logLevel := logrus.GetLevel()

Expand Down
2 changes: 1 addition & 1 deletion e2e/_suites/helm/helm_charts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion e2e/_suites/kubernetes-autodiscover/autodiscover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a89325c

Please sign in to comment.