8000 Improve test log format by MichaelSnowden · Pull Request #3634 · temporalio/temporal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve test log format #3634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/log/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ type (
Level string `yaml:"level"`
// OutputFile is the path to the log output file
OutputFile string `yaml:"outputFile"`
// Format determines the format of each log file printed to the output.
// Acceptable values are "json" or "console". The default is "json".
// Use "console" if you want stack traces to appear on multiple lines.
Format string `yaml:"format"`
}
)
8 changes: 7 additions & 1 deletion common/log/zap_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func NewTestLogger() *zapLogger {
return NewZapLogger(BuildZapLogger(Config{
// Uncomment next line if you need debug level logging in tests.
// Level: "debug",
Format: "console",
}))
}

Expand Down Expand Up @@ -197,11 +198,16 @@ func buildZapLogger(cfg Config, disableCaller bool) *zap.Logger {
outputPath = "stdout"
}

encoding := "json"
if cfg.Format == "console" {
encoding = "console"
}

config := zap.Config{
Level: zap.NewAtomicLevelAt(parseZapLevel(cfg.Level)),
Development: false,
Sampling: nil,
Encoding: "json",
Encoding: encoding,
EncoderConfig: encodeConfig,
OutputPaths: []string{outputPath},
ErrorOutputPaths: []string{outputPath},
Expand Down
0