Skip to content
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

Port previous NewTestLogger flags over #7432

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stephanos
Copy link
Contributor

@stephanos stephanos commented Mar 6, 2025

What changed?

Ports TEMPORAL_TEST_LOG_FORMAT and TEMPORAL_TEST_LOG_LEVEL to testlogger.TestLogger.

Why?

To not break developer setups.

How did you test it?

Potential risks

Documentation

Is hotfix candidate?

@stephanos stephanos force-pushed the support-TEMPORAL_TEST_LOG_FORMAT branch 4 times, most recently from 3f2149b to ea29fc2 Compare March 6, 2025 00:19
Comment on lines -207 to -218
func WithoutCaller() LoggerOption {
return func(t *TestLogger) {
t.state.logCaller = false
}
}

func LogCaller() LoggerOption {
return func(t *TestLogger) {
t.state.logCaller = false
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work together with log.BuildZapLogger which defaults to disabling this. Removing it for now.

@@ -55,13 +56,13 @@ var _ Logger = (*zapLogger)(nil)

// NewTestLogger returns a logger for tests
func NewTestLogger() *zapLogger {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a ticket to remove this function and replace it with testlogger.TestLogger.

@stephanos stephanos force-pushed the support-TEMPORAL_TEST_LOG_FORMAT branch from ea29fc2 to 1269009 Compare March 6, 2025 00:21
@stephanos stephanos changed the title Backport previous NewTestLogger flags Port previous NewTestLogger flags Mar 6, 2025
@stephanos stephanos changed the title Port previous NewTestLogger flags Port previous NewTestLogger flags over Mar 6, 2025
if format == "" {
format = "console"
}

logger := BuildZapLogger(Config{
Level: os.Getenv(testLogLevelEnvVar),
Level: os.Getenv(TestLogLevelEnvVar),
Format: format,
Development: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we port this too? it looks like it controls whether it panics on dpanic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new TestLogger already has a flag panicOnDPanic which by default is true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need envs to control test logger? Do we use it anywhere?

Copy link
Contributor Author

@stephanos stephanos Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

David does to switch it to JSON format; and I noticed that I actually set up my IDE to log on error level instead of debug level. So that's two use cases already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know we have it.

@stephanos stephanos marked this pull request as ready for review March 6, 2025 00:59
@stephanos stephanos requested a review from a team as a code owner March 6, 2025 00:59
@stephanos stephanos requested a review from alexshtin March 6, 2025 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants