We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
micro/logger/options.go
Line 32 in bff40bd
Because of the shared slice with capacity of 6, multiple cloned loggers write fields to the same place.
package main import ( "context" "fmt" zerolog "go.unistack.org/micro-logger-zerolog/v3" "go.unistack.org/micro/v3/logger" ) func main() { logger.DefaultLogger = zerolog.NewLogger( zerolog.ReportCaller(), logger.WithLevel(logger.InfoLevel), logger.WithCallerSkipCount(5), //logger.WithFields(), ) if err := logger.DefaultLogger.Init(); err != nil { panic(err) } ctx := context.Background() fields := func() any { return logger.DefaultLogger.Clone().Options().Fields } log := logger.DefaultLogger.Clone().Fields("my", "name", "is", "jojo") log2 := logger.DefaultLogger.Clone().Fields("who", "are") fmt.Printf("fields: %v (%p)\n", fields(), fields()) fmt.Printf("log fields: %v (%p)\n", log.Options().Fields, log.Options().Fields) fmt.Printf("log2 fields: %v (%p)\n", log2.Options().Fields, log2.Options().Fields) logger.DefaultLogger.Clone().Fields("hello", "world").Trace(ctx) fmt.Printf("fields: %v (%p)\n", fields(), fields()) fmt.Printf("log fields: %v (%p)\n", log.Options().Fields, log.Options().Fields) fmt.Printf("log2 fields: %v (%p)\n", log2.Options().Fields, log2.Options().Fields) }
module demo go 1.20 require ( go.unistack.org/micro-logger-zerolog/v3 v3.8.4 go.unistack.org/micro/v3 v3.10.39 ) require ( github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rs/zerolog v1.29.0 // indirect golang.org/x/sys v0.7.0 // indirect )
fields: [] (0xc0000b4300) log fields: [who are is jojo] (0xc0000b4300) log2 fields: [who are] (0xc0000b4300) fields: [] (0xc0000b4300) log fields: [hello world is jojo] (0xc0000b4300) log2 fields: [hello world] (0xc0000b4300)
fields: [] (0x0) log fields: [my name is jojo] (0xc0000d0040) log2 fields: [who are] (0xc0000ce0c0) fields: [] (0x0) log fields: [my name is jojo] (0xc0000d0040) log2 fields: [who are] (0xc0000ce0c0)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
micro/logger/options.go
Line 32 in bff40bd
Because of the shared slice with capacity of 6, multiple cloned loggers write fields to the same place.
Snippet:
Actual result:
Expected:
The text was updated successfully, but these errors were encountered: