Commit 5338f96 1 parent 4f53af9 commit 5338f96 Copy full SHA for 5338f96
File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,9 @@ import (
40
40
const (
41
41
skipForZapLogger = 3
42
42
// we put a default message when it is empty so that the log can be searchable/filterable
43
- defaultMsgForEmpty = "none"
43
+ defaultMsgForEmpty = "none"
44
+ testLogFormatEnvVar = "TEMPORAL_TEST_LOG_FORMAT" // set to "json" for json logs in tests
45
+ testLogLevelEnvVar = "TEMPORAL_TEST_LOG_LEVEL" // set to "debug" for debug level logs in tests
44
46
)
45
47
46
48
type (
@@ -53,12 +55,15 @@ type (
53
55
54
56
var _ Logger = (* zapLogger )(nil )
55
57
56
- // NewTestLogger returns a logger at debug level and log into STDERR
58
+ // NewTestLogger returns a logger for tests
57
59
func NewTestLogger () * zapLogger {
60
+ format := os .Getenv (testLogFormatEnvVar )
61
+ if format == "" {
62
+ format = "console"
63
+ }
58
64
return NewZapLogger (BuildZapLogger (Config {
59
- // Uncomment next line if you need debug level logging in tests.
60
- // Level: "debug",
61
- Format : "console" ,
65
+ Level : os .Getenv (testLogLevelEnvVar ),
66
+ Format : format ,
62
67
Development : true ,
63
68
}))
64
69
}
You can’t perform that action at this time.
0 commit comments