uber-go / zap

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

Add custom configurable separator for console logger before start of the message. #1427

Open s3rj1k opened 7 months ago

s3rj1k commented 7 months ago

Describe the solution you'd like It would be nice to have custom configurable separator for console logger before start of the message similar to how now is general separator is configured, so that log lines can be configured as follows:

2024-04-07T12:39:51Z    INFO    local/main.go:19    Server is running   {"addr": ":8080"}

vs

2024-04-07T12:39:51Z    INFO    local/main.go:19]   Server is running   {"addr": ":8080"}

Basically adding ]<TAB> (configurable opt-in) as delimiter between start of message and all other default fields.

Describe alternatives you've considered Alternative would be to implement custom console_encoder but it feels like an overkill for adding single additional opt-in delimiter.

Is this a breaking change? Change is backwards compatible, just adds new field in EncoderConfig that will only be processed by console encoder with the default value of ConsoleSeparator field. (New field can be named ConsoleMessageWithFieldsSeparator)