From 0efdadb11066b572ccac2d4ee654396ecaf22623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Tue, 10 Sep 2024 16:05:44 +0200 Subject: [PATCH] feat(plc4go/spi): add mute log environment variable --- plc4go/spi/testutils/TestUtils.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plc4go/spi/testutils/TestUtils.go b/plc4go/spi/testutils/TestUtils.go index 4e6cdb2d1c5..9c1bb7d7250 100644 --- a/plc4go/spi/testutils/TestUtils.go +++ b/plc4go/spi/testutils/TestUtils.go @@ -125,6 +125,7 @@ func TestContext(t *testing.T) context.Context { } var ( + muteLog bool highLogPrecision bool passLoggerToModel bool receiveTimeout time.Duration @@ -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 @@ -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),