Skip to content

Improve pretty logger #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Improve pretty logger #9

wants to merge 9 commits into from

Conversation

fpawel
Copy link

@fpawel fpawel commented Jul 15, 2023

image
Golals:

  • correct processing of structural logging groups
  • correct implementation of the interface interface { WithGroup(name string) slog.Handler } in accordance with slog contract
  • additional logger options useful for local debugging

for example the following statement

log.WithGroup("group1").WithGroup("group2").Info("msg", slog.Group("group3", slog.Group("group4", "k1", "v1", "k2", "v2")))

produces something like the following output with the original version of the logger from the current main branch

[20:16:16.624] INFO: msg {
  "group3": [
    {
      "Key": "group4",
      "Value": {}
    }
  ]
}

and more meaningful output with corrected logger

INFO msg {"group1":{"group2":{"group3":{"group4":{"k1":"v1","k2":"v2"}}}}} main.go:31.main

Pease don't forget to squash before merge

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.

1 participant