Would it make sense to include structured input types similar to how zerolog works? #300
-
One thing I really like about zerolog is using The other part about providing |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
I like the idea, but I don't know all the "logging magic" and best practices. I would definitely need someone to help me with the planning of such a feature, as I don't use loggers often (I am more of a CLI tool person ^^). However, currently you could do that by creating an own printer: printError := pterm.Error.WithShowLineNumber().WithScope(pterm.Scope{Text: "some-scope"}).Println
err := errors.New("some error")
printError(err) |
Beta Was this translation helpful? Give feedback.
-
Revisited this issue after serving Charm release their new logging package. https://github.com/charmbracelet/log Still using pterm for most projects but having an option to toggle structured logs out and provide name value pairs would be interesting. Might also pair well with the experiential slog proposal, ie needing compatible with this later on. Pterm fits an interesting area as I use it for pretty output tooling but often it's primary usage crosses over into a leveled logger for me. |
Beta Was this translation helpful? Give feedback.
-
The proposal for structured logging in the standard library was just accepted: golang/go#56345 I will wait for it to be stable, and maybe we can integrate it into PTerm, so that our structured logging is compatible with the standard library. Will be interesting! |
Beta Was this translation helpful? Give feedback.
-
The proposal was accepted and is now to be discussed in #470. |
Beta Was this translation helpful? Give feedback.
The proposal was accepted and is now to be discussed in #470.
Thanks for the suggestion and the contribution! :)