log: disable console when StderrLevel is above Error#6
Merged
Conversation
The pretty console added in #3 maps every slog threshold at or above Error to pterm's Error level, so a caller can no longer mute the console. The old tint sink honored a numeric threshold, so StderrLevel of slog.LevelError+1 silenced it. Callers that render their own pterm output, like cmd/infra's feedback lines, now get every Error line twice because both their render and signals' console print it. Map a threshold above Error to pterm.LogLevelDisabled, restoring the mute: StderrLevel of slog.LevelError+1 silences the console sink while OTLP still ships every level. Adds ptermLevel and console-mute tests.
There was a problem hiding this comment.
Pull request overview
This PR restores the ability for callers to fully mute the pterm-backed stderr console sink by treating StderrLevel > slog.LevelError as “disabled”, while leaving the OTLP exporter behavior unchanged (still exports all levels).
Changes:
- Update
ptermLevelso thresholds aboveslog.LevelErrormap topterm.LogLevelDisabled(mute console). - Add unit tests that lock the mapping behavior and verify console muting even for
Errorrecords. - Document the “
slog.LevelError+1disables console” behavior inConfig.StderrLevelandptermLeveldocs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| log.go | Adjusts slog→pterm level mapping so console can be disabled when the threshold is above Error. |
| log_internal_test.go | Adds tests for the new mapping and for fully muted console output. |
| config.go | Documents that StderrLevel > Error disables the console sink entirely. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
turkosaurus
added a commit
that referenced
this pull request
Jul 6, 2026
This reverts commit 8f8270b.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pretty console added in #3 maps every slog threshold at or above Error to pterm's Error level, so a caller can no longer mute the console. The old tint sink honored a numeric threshold, so StderrLevel of slog.LevelError+1 silenced it. Callers that render their own pterm output, like cmd/infra's feedback lines, now get every Error line twice because both their render and signals' console print it.
This maps a threshold above Error to pterm.LogLevelDisabled, restoring the mute: StderrLevel of slog.LevelError+1 silences the console sink while OTLP still ships every level. Adds ptermLevel and console-mute tests.
Verified against cmd/infra with a local replace: non-verbose now prints one line (the caller's badge) instead of two, and -v still shows the signals stream.