Skip to content

log: disable console when StderrLevel is above Error#6

Merged
turkosaurus merged 1 commit into
mainfrom
turk/console-mute
Jul 5, 2026
Merged

log: disable console when StderrLevel is above Error#6
turkosaurus merged 1 commit into
mainfrom
turk/console-mute

Conversation

@turkosaurus

Copy link
Copy Markdown
Contributor

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 ptermLevel so thresholds above slog.LevelError map to pterm.LogLevelDisabled (mute console).
  • Add unit tests that lock the mapping behavior and verify console muting even for Error records.
  • Document the “slog.LevelError+1 disables console” behavior in Config.StderrLevel and ptermLevel docs.

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
turkosaurus merged commit 8f8270b into main Jul 5, 2026
3 checks passed
@turkosaurus
turkosaurus deleted the turk/console-mute branch July 5, 2026 23:15
turkosaurus added a commit that referenced this pull request Jul 6, 2026
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.

2 participants