uber-go / zap

Blazing fast, structured, leveled logging in Go.
https://pkg.go.dev/go.uber.org/zap
MIT License
21.28k stars 1.41k forks source link

Allow pretty printing for formattable errors #732

Open ghostsquad opened 4 years ago

ghostsquad commented 4 years ago

Since I use pkg/errors, each error satisfies the fmt.Formatter interface and thus, every error log comes with a cause trace in the errorVerbose field.. This is great in production, but during development, (i.e. with NewDevelopmentConfig), I'd like to see the cause trace in a non-json field so that I can read it.

Right now, the formatting is that it provides several lines, separated by \n which get shoved into the errorVerbose field. Imagine if the stacktrace provided by Zap were to be shoved into a field in development mode. It would be very hard to read.

this issue forked from https://github.com/uber-go/zap/issues/650

yqylovy commented 4 years ago

Same case,I change check , it's not clean code, but it works... https://github.com/yqylovy/zap/commit/43dc4e1e29e672396ec777213acd308f4cc95e2e

ghostsquad commented 4 years ago

@yqylovy what makes you say it's not clean code?

yqylovy commented 4 years ago

When there is an errors packet, it will directly modify the stack, so different inputs will cause different behaviors.

yqylovy commented 4 years ago

make it configurable. https://github.com/uber-go/zap/compare/master...yqylovy:master