Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
fix: avoid setting duplicate log attrs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
palkan committed Feb 26, 2024
1 parent 3cf30a7 commit 2ce7245
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2ce7245

Please sign in to comment.