From 2ce7245759585900bd4c3949e79368a8cd36dfde Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Sun, 25 Feb 2024 19:13:20 -0800 Subject: [PATCH] fix: avoid setting duplicate log attrs Remove context=main from the core logger; context must be set only by components. Why? slog doesn't override attributes by default but duplicate them in the output instead. Let's not deal with custom handlers, etc. and follow slog design --- cli/cli.go | 2 +- rpc/rpc.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 145f4f77..b8bfdbbb 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -104,7 +104,7 @@ func (r *Runner) checkAndSetDefaults() error { return errorx.Decorate(err, "failed to initialize default logger") } - r.log = slog.With("context", "main").With("nodeid", r.config.ID) + r.log = slog.With("nodeid", r.config.ID) } err := r.config.LoadPresets(r.log) diff --git a/rpc/rpc.go b/rpc/rpc.go index db055d03..fa4e1505 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -506,7 +506,7 @@ func defaultDialer(conf *Config, l *slog.Logger) (pb.RPCClient, ClientHelper, er const grpcServiceConfig = `{"loadBalancingPolicy":"round_robin"}` - state := &grpcClientHelper{log: l.With("context", "grpc")} + state := &grpcClientHelper{log: l.With("impl", "grpc")} dialOptions := []grpc.DialOption{ grpc.WithKeepaliveParams(kacp),