Skip to content

Commit

Permalink
feat(plc4go/spi): add mute log environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Sep 10, 2024
1 parent e6859e6 commit 0efdadb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plc4go/spi/testutils/TestUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func TestContext(t *testing.T) context.Context {
}

var (
muteLog bool
highLogPrecision bool
passLoggerToModel bool
receiveTimeout time.Duration
Expand All @@ -136,6 +137,7 @@ var (
)

func init() {
getOrLeaveBool("PLC4X_TEST_MUTE_LOG", &muteLog)
getOrLeaveBool("PLC4X_TEST_HIGH_TEST_LOG_PRECISION", &highLogPrecision)
if highLogPrecision {
zerolog.TimeFieldFormat = time.RFC3339Nano
Expand Down Expand Up @@ -188,6 +190,9 @@ type TestingLog interface {

// ProduceTestingLogger produces a logger which redirects to testing.T
func ProduceTestingLogger(t TestingLog) zerolog.Logger {
if muteLog {
return zerolog.Nop()
}
noColor := shouldNoColor()
consoleWriter := zerolog.NewConsoleWriter(
zerolog.ConsoleTestWriter(t),
Expand Down

0 comments on commit 0efdadb

Please sign in to comment.