Add env vars to control log format and level for tests
@@ -41,6 +41,8 @@ const (
skipForZapLogger = 3
// we put a default message when it is empty so that the log can be searchable/filterable
defaultMsgForEmpty = "none"
+ testLogFormatEnvVar = "TEMPORAL_TEST_LOG_FORMAT" // set to "json" for json logs in tests
+ testLogLevelEnvVar = "TEMPORAL_TEST_LOG_LEVEL" // set to "debug" for debug level logs in tests
)
type (
@@ -53,12 +55,15 @@ type (
var _ Logger = (*zapLogger)(nil)
-// NewTestLogger returns a logger at debug level and log into STDERR
+// NewTestLogger returns a logger for tests
func NewTestLogger() *zapLogger {
+ format := os.Getenv(testLogFormatEnvVar)
+ if format == "" {
+ format = "console"
+ }
return NewZapLogger(BuildZapLogger(Config{
- // Uncomment next line if you need debug level logging in tests.
- // Level: "debug",
- Format: "console",
+ Level: os.Getenv(testLogLevelEnvVar),
+ Format: format,
Development: true,
}))
}
