Skip to content

chore: update TBLogHandler#269

Open
JonathanOppenheimer wants to merge 7 commits intomainfrom
JonathanOppenheimer/ethtest-tbhandler-error-level
Open

chore: update TBLogHandler#269
JonathanOppenheimer wants to merge 7 commits intomainfrom
JonathanOppenheimer/ethtest-tbhandler-error-level

Conversation

@JonathanOppenheimer
Copy link
Member

Why this should be merged

We decided that geth warnings should not be surfaced as errors in strevm, due to there being far too many false/meaningless warnings. Now Enabled() enables all logs (visible via tb.Logf for debugging) and Handle() uses h.level as the tb.Errorf threshold, so e.g. NewTBLogHandler(tb, slog.LevelError) only fails the test on errors, not warnings.

How this was tested

I updated TestTBLogHandler appropriately.

l.Info("Hello", "who", "world")
l.Warn("Smoke")
l.Error("Fire")
// Crit will call os.Exit(1) so we don't test it.
Copy link

Choose a reason for hiding this comment

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

Not saying this is necessarily better, but I did find a janky way to test this:

func (r *tbRecorder) Fatalf(format string, a ...any) {
	panic(fmt.Sprintf(format, a...))
}

// in test
require.Panics(t, func() { l.Crit("Explosion") })

By panicking, we avoid calling os.Exit, but we can ensure that it's called. This might be awful though, so don't feel the need to include this. Just being creative

Copy link
Member Author

Choose a reason for hiding this comment

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

If panic is okay behavior, I'm fine with this. I'll implement and let someone else chime in.

JonathanOppenheimer and others added 2 commits March 3, 2026 10:51
Co-authored-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Signed-off-by: Jonathan Oppenheimer <147infiniti@gmail.com>
doLogging := func(t *testing.T, l log.Logger) {
t.Helper()
l.Debug("Hi")
l.Info("Austin", "you", "are")
Copy link

Choose a reason for hiding this comment

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

What happened to "you" and "are"?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean what happened?

Copy link

Choose a reason for hiding this comment

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

What's the point of writing it in the test if you don't assert that the strings are carried through?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah when I reworked it I just accessed from the message. I was just trying to keep it fun. I changed it now so everything is covered, and it reads properly in the setup and in the test table 😂.

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