Skip to content

Improve terminal readability for async logs by deduplicating repeated headers #81

@sunnynarula

Description

@sunnynarula

Description

When using Console with async runtimes (e.g. Falcon + Async + Rails), logs become difficult to read for humans due to repeated, identical headers being printed for every log event.

This is especially noticeable in development when scanning logs in a terminal.


Problem

In async environments, many consecutive log events share the same execution context (subject + annotations), but Console prints the full header for every event.

Example (simplified):

debug: Rails: Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server.
| User Load (0.5ms) SELECT ...
debug: Rails: Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server.
| ↳ app/controllers/users/sessions_controller.rb:36
debug: Rails: Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server.
| TRANSACTION BEGIN

The information is correct, but the repeated header:

debug: Rails: Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server.

adds significant visual noise and makes it hard to scan SQL, controller flow, and rendering steps.

Because async execution interleaves events from different fibers, ordering cannot be made deterministic — but repeating identical headers provides no additional information.


Observation

In practice:

  • Many consecutive events share the same:
    • subject (e.g. Rails)
    • annotations (e.g. HTTP protocol / request loop)
  • The header only needs to be shown once per context
  • Humans naturally group log lines visually rather than by strict order

Proposed Solution

Introduce an optional terminal output mode that deduplicates consecutive identical headers.

Tentative names:

  • Console::Output::TerminalSummary
  • Terminal::Compact
  • Terminal::Grouped

Behavior:

  • Track the previously rendered header
  • If the current event’s header matches the previous one:
    • suppress the header
    • print only the indented body
  • If the header changes:
    • print the full header again

This would dramatically improve readability while preserving all log information.


Explicit Non-Goals

This proposal intentionally does not:

  • reorder events
  • group logs by request or fiber
  • infer request boundaries
  • change logging semantics
  • affect machine-readable outputs (Serialized)

It is purely a presentation-layer improvement for human-readable terminal output.


Why This Belongs in Console

  • The issue is at the output formatting layer
  • Console already owns:
    • header rendering
    • subject formatting
    • indentation rules
  • No changes are required in:
    • Rails
    • Falcon
    • Async
    • application code

The feature would be:

  • opt-in
  • backwards-compatible
  • low risk

Possible Configuration

Examples (naming flexible):

CONSOLE_OUTPUT=TerminalSummary

or

CONSOLE_OUTPUT=Terminal
CONSOLE_COMPACT_HEADERS=1

or via config/console.rb.

Context

This issue arose during real-world use of Console with:

  • Ruby on Rails
  • Falcon
  • Async
  • concurrent request handling in development

The async execution model is correct and expected; this proposal focuses solely on improving human log readability under that model.

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