File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ func (s *svc) HandleOrder(ctx context.Context, req *proto.OrderRequest) (*proto.
2626 slog.String (" order_id" , req.GetOrderId ()),
2727 slog.Int (" items" , len (req.GetItems ())),
2828 )
29- // ...
29+ // ... business logic ...
30+ return &proto.OrderResponse {}, nil
3031}
3132```
3233
@@ -115,6 +116,10 @@ func init() {
115116 // Wrap with any slog.Handler middleware — e.g., slog-sampling, slog-dedup, etc.
116117 // NewSamplingHandler is a placeholder for your chosen middleware.
117118 sampled := NewSamplingHandler (cbHandler, 0.1 )
119+
120+ // Use log.SetDefault for ColdBrew's handler so log.GetHandler()/log.SetLevel() work,
121+ // then override slog.SetDefault with the wrapped version for native slog calls.
122+ log.SetDefault (cbHandler)
118123 slog.SetDefault (slog.New (sampled))
119124}
120125```
You can’t perform that action at this time.
0 commit comments