Skip to content

[go] Pad pretty-print header when goroutine id printed #21

@gabe-l-hart

Description

@gabe-l-hart

Description

As a developer using pretty-print formatting to view my logs, I want the headers to all align so that I can visually scan my log output.

Details

Currently, when enabling -log.goroutine-id, the logging may look like:

2021/08/08 20:32:33 <example-server> [MAIN :INFO:1] Logging Configured!
2021/08/08 20:32:33 <example-server> [MAIN :INFO:1] Hello World!
2021/08/08 20:32:34 <example-server> [HNDLR:WARN:19]   WATCH OUT!
2021/08/08 20:32:34 <example-server> [HNDLR:INFO:19]   Standard stuff...
2021/08/08 20:32:34 <example-server> [HNDLR:WARN:5]   WATCH OUT!
2021/08/08 20:32:34 <example-server> [HNDLR:INFO:5]   Standard stuff...
2021/08/08 20:32:34 <example-server> [HNDLR:DBUG:5]   Query Params:

In this example, the length of the goroutine-id portion of the pretty-print header is different on different lines, making visual parsing difficult.

Acceptance Criteria

  • Pretty-print headers are a fixed width (possibly increasing as max-length goroutine-id seen, but never decreasing)
  • Json formatting is unchanged
  • The implementation does not need to look-ahead at future logs to determine the padding size
  • Padding validated in unit tests

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions