Skip to content

feat: Refactor Logger for Pretty, Consistent CLI Output #75

@drlucaa

Description

@drlucaa

The current logger adapter uses log/slog's default text handler, which outputs structured key-value pairs (e.g., level=INFO msg="..."). This style conflicts with the polished, human-readable output generated by the linear renderer used during same run.

We need to refactor the logger to produce visually consistent, "pretty" output for standalone commands like clean and version. The new implementation should strip away structured logging artifacts (timestamps, levels, keys) in favor of styled, direct text that respects the user's terminal environment.

Goals

  • Visual Consistency: Ensure all CLI output shares the same aesthetic (colors, spacing, typography) as the build execution logs.
  • Shared Design System: Centralize color and icon definitions to prevent visual drift between the TUI, linear renderer, and logger.
  • TTY Awareness: Strictly respect NO_COLOR and terminal capabilities.

Acceptance Criteria

1. Style & Formatting

  • Info Logs:
    • Icon: None. (Text only).
    • Color: Default/Slate (Neutral).
    • Format: <Message> (No timestamp, no level= key).
  • Warn Logs:
    • Icon: ! (or similar warning symbol).
    • Color: Yellow.
    • Format: <Icon> <Message>.
  • Error Logs:
    • Icon: (Cross mark).
    • Color: Red.
    • Format: <Icon> <Message>.
  • Prefixes: The output must NOT include tool prefixes (e.g., remove [same], [cli]).

2. Implementation

  • Shared Package: Extract colors (colorIris, colorRed, etc.) and icons from internal/adapters/tui/styles.go into a new shared package (e.g., internal/ui/style) usable by all adapters.
  • Logger Adapter: Refactor internal/adapters/logger to remove slog.NewTextHandler. Implement a custom handler (or wrapper) using github.com/muesli/termenv to render styled text directly to os.Stderr.
  • Environment: The logger must detect TTY capabilities and respect the NO_COLOR environment variable (stripping ANSI codes if set).

3. Verification

  • Running same clean produces output similar to:
    Removing build info store...
    removed build info store
    
    (Note: No icons for these info logs, no level= keys).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions