Skip to content

Commit

Permalink
fix pipleline failure for log_test (#1110)
Browse files Browse the repository at this point in the history
Signed-off-by: Amruta Kale <amrutakale24.1991@gmail.com>
  • Loading branch information
kale-amruta committed Oct 7, 2021
1 parent a4f8a4b commit 738d500
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func testLogMessage(c *C, msg string, print func(string, ...field.M), fields ...
}

func (s *LogSuite) TestLogLevel(c *C) {
os.Unsetenv(LevelEnvName)
initLogLevel()
log.SetFormatter(&logrus.JSONFormatter{TimestampFormat: time.RFC3339Nano})

var output bytes.Buffer
Expand All @@ -122,8 +124,11 @@ func (s *LogSuite) TestLogLevel(c *C) {
c.Assert(output.String(), HasLen, 0)

//Check if debug level log is printed when log level is debug
os.Setenv("LOG_LEVEL", "debug")
defer os.Unsetenv("LOG_LEVEL")
os.Setenv(LevelEnvName, "debug")
defer func() {
os.Unsetenv(LevelEnvName)
initLogLevel()
}()
initLogLevel()
Debug().WithContext(ctx).Print("Testing debug level")
cerr := json.Unmarshal(output.Bytes(), &entry)
Expand Down

0 comments on commit 738d500

Please sign in to comment.