Skip to content

log: align pterm prefix-printer badge widths#5

Merged
turkosaurus merged 3 commits into
mainfrom
turk/pterm-badge-widths
Jul 5, 2026
Merged

log: align pterm prefix-printer badge widths#5
turkosaurus merged 3 commits into
mainfrom
turk/pterm-badge-widths

Conversation

@turkosaurus

Copy link
Copy Markdown
Contributor

What

The console logger's own level tags already render at a uniform 5 columns (pterm's %-5s), but pterm's global PrefixPrinter singletons — pterm.Info, pterm.Warning, pterm.Error, etc., which a consumer prints directly — ship at mixed widths: INFO is a 4-wide cyan block while WARNING/SUCCESS/ERROR/FATAL/DEBUG are 7. Their background-colored badges stagger.

This normalizes the set to one width (7), centered:

  INFO     WARNING    SUCCESS    ERROR     FATAL     DEBUG

Only INFO actually changes; every other badge is already 7.

How

alignPrefixBadges() (plus a centerPad helper) runs once in consoleHandler, alongside the existing pterm-global color config. pterm's printers are process-global singletons, so this reaches every consumer that calls Logger() — no extra action on their part, the same fleet-wide side effect the package already applies to color. The pass is idempotent, so repeated Logger() calls don't drift the width.

The console logger's own level tags already render at a uniform 5
columns via pterm's %-5s, but pterm's global PrefixPrinter singletons
(pterm.Info/Warning/Error/... that a consumer prints directly) ship at
mixed widths: INFO is a 4-wide cyan block while WARNING/SUCCESS/ERROR/
FATAL/DEBUG are 7. Their background-colored badges stagger.

Normalize them to one width, centered, set once alongside the existing
pterm-global color config in consoleHandler. pterm's printers are
process-global singletons, so this holds for every consumer that calls
Logger() with no extra action on their part -- the same fleet-wide
consistency side effect the package already applies to color. The pass
is idempotent, so repeated Logger() calls don't drift the width.

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 normalizes the visual width/labeling of pterm’s process-global PrefixPrinter badges (pterm.Info, pterm.Warning, etc.) so consumer-facing badge blocks align consistently when using the signals console logger.

Changes:

  • Add alignPrefixBadges() (with centerPad) and call it from consoleHandler to normalize pterm global badge labels/widths.
  • Add TestBadges as a manual/visual exercise for the aligned prefix printers plus a background-color palette preview.
  • Add a badges subcommand to ./bin/test to run the new badge print test with forced color.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
pretty_test.go Adds TestBadges to print/inspect aligned pterm prefix-printer badges and a palette sample.
log.go Normalizes pterm global prefix-printer badge texts via alignPrefixBadges() and a centerPad helper.
bin/test Adds a badges command to run TestBadges with CLICOLOR_FORCE=1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread log.go Outdated
Comment thread pretty_test.go
@turkosaurus
turkosaurus merged commit 9fd4bd1 into main Jul 5, 2026
2 checks passed
@turkosaurus
turkosaurus deleted the turk/pterm-badge-widths branch July 5, 2026 21:40
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