Open yqaty opened 2 months ago
ConsoleWriter.Write processes custom fields specified in PartsOrder to output only their values instead of the key-value pairs. In practice:
ConsoleWriter.Write
PartsOrder
package main import ( "github.com/rs/zerolog" ) func main() { cw := zerolog.NewConsoleWriter() cw.PartsOrder = append(cw.PartsOrder, "k1") logger := zerolog.New(cw).With().Timestamp().Logger() logger.Info().Str("k1", "v1").Msg("hello world") }
Actual output:
5:09PM INF hello world v1 k1=v1
The field k1 is duplicated, and the expected output is:
k1
5:09PM INF hello world v1
This is due to a bug in ConsoleWrite.writeFields where it filters fields based on the default PartsOrder rather than the current PartsOrder.
ConsoleWrite.writeFields
ConsoleWriter.Write
processes custom fields specified inPartsOrder
to output only their values instead of the key-value pairs. In practice:Actual output:
The field
k1
is duplicated, and the expected output is:This is due to a bug in
ConsoleWrite.writeFields
where it filters fields based on the defaultPartsOrder
rather than the currentPartsOrder
.