slog: rename Handler.With to Handler.WithAttrs

Change-Id: I44b8c9c18d24fc59a59a325c6393972d5b5f552b
Reviewed-on: https://go-review.googlesource.com/c/exp/+/442791
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/slog/benchmarks/handlers.go b/slog/benchmarks/handlers.go
index 4146154..7362871 100644
--- a/slog/benchmarks/handlers.go
+++ b/slog/benchmarks/handlers.go
@@ -92,7 +92,7 @@
 	*buf = strconv.AppendInt(*buf, t.Unix(), 10)
 }
 
-func (h *fastTextHandler) With([]slog.Attr) slog.Handler {
+func (h *fastTextHandler) WithAttrs([]slog.Attr) slog.Handler {
 	panic("fastTextHandler: With unimplemented")
 }
 
@@ -124,7 +124,7 @@
 	return nil
 }
 
-func (*asyncHandler) With([]slog.Attr) slog.Handler {
+func (*asyncHandler) WithAttrs([]slog.Attr) slog.Handler {
 	panic("asyncHandler: With unimplemented")
 }
 
@@ -137,7 +137,7 @@
 func (disabledHandler) Enabled(slog.Level) bool  { return false }
 func (disabledHandler) Handle(slog.Record) error { panic("should not be called") }
 
-func (disabledHandler) With([]slog.Attr) slog.Handler {
+func (disabledHandler) WithAttrs([]slog.Attr) slog.Handler {
 	panic("disabledHandler: With unimplemented")
 }
 
diff --git a/slog/handler.go b/slog/handler.go
index 1ed8dd2..88f15dc 100644
--- a/slog/handler.go
+++ b/slog/handler.go
@@ -35,10 +35,10 @@
 	//   - If an Attr's key is the empty string, ignore the Attr.
 	Handle(r Record) error
 
-	// With returns a new Handler whose attributes consist of
+	// WithAttrs returns a new Handler whose attributes consist of
 	// the receiver's attributes concatenated with the arguments.
 	// The Handler owns the slice: it may retain, modify or discard it.
-	With(attrs []Attr) Handler
+	WithAttrs(attrs []Attr) Handler
 
 	// WithGroup returns a new Handler with the given group appended to
 	// the receiver's existing groups.
@@ -92,7 +92,7 @@
 	return h.output(4, buf.String())
 }
 
-func (h *defaultHandler) With(as []Attr) Handler {
+func (h *defaultHandler) WithAttrs(as []Attr) Handler {
 	return &defaultHandler{h.ch.withAttrs(as), h.output}
 }
 
diff --git a/slog/handler_test.go b/slog/handler_test.go
index e02003e..fb5080d 100644
--- a/slog/handler_test.go
+++ b/slog/handler_test.go
@@ -35,7 +35,7 @@
 		},
 		{
 			name:  "preformatted",
-			with:  func(h Handler) Handler { return h.With(preAttrs) },
+			with:  func(h Handler) Handler { return h.WithAttrs(preAttrs) },
 			attrs: attrs,
 			want:  "INFO message pre=0 a=1 b=two",
 		},
@@ -53,16 +53,16 @@
 		},
 		{
 			name:  "group",
-			with:  func(h Handler) Handler { return h.With(preAttrs).WithGroup("s") },
+			with:  func(h Handler) Handler { return h.WithAttrs(preAttrs).WithGroup("s") },
 			attrs: attrs,
 			want:  "INFO message pre=0 s·a=1 s·b=two",
 		},
 		{
 			name: "preformatted groups",
 			with: func(h Handler) Handler {
-				return h.With([]Attr{Int("p1", 1)}).
+				return h.WithAttrs([]Attr{Int("p1", 1)}).
 					WithGroup("s1").
-					With([]Attr{Int("p2", 2)}).
+					WithAttrs([]Attr{Int("p2", 2)}).
 					WithGroup("s2")
 			},
 			attrs: attrs,
@@ -71,7 +71,7 @@
 		{
 			name: "two with-groups",
 			with: func(h Handler) Handler {
-				return h.With([]Attr{Int("p1", 1)}).
+				return h.WithAttrs([]Attr{Int("p1", 1)}).
 					WithGroup("s1").
 					WithGroup("s2")
 			},
@@ -154,7 +154,7 @@
 		},
 		{
 			name:     "preformatted",
-			with:     func(h Handler) Handler { return h.With(preAttrs) },
+			with:     func(h Handler) Handler { return h.WithAttrs(preAttrs) },
 			preAttrs: preAttrs,
 			attrs:    attrs,
 			wantText: "time=2000-01-02T03:04:05.000Z level=INFO msg=message pre=3 x=y a=one b=2",
@@ -163,7 +163,7 @@
 		{
 			name:     "preformatted cap keys",
 			replace:  upperCaseKey,
-			with:     func(h Handler) Handler { return h.With(preAttrs) },
+			with:     func(h Handler) Handler { return h.WithAttrs(preAttrs) },
 			preAttrs: preAttrs,
 			attrs:    attrs,
 			wantText: "TIME=2000-01-02T03:04:05.000Z LEVEL=INFO MSG=message PRE=3 X=y A=one B=2",
@@ -172,7 +172,7 @@
 		{
 			name:     "preformatted remove all",
 			replace:  removeAll,
-			with:     func(h Handler) Handler { return h.With(preAttrs) },
+			with:     func(h Handler) Handler { return h.WithAttrs(preAttrs) },
 			preAttrs: preAttrs,
 			attrs:    attrs,
 			wantText: "",
@@ -188,7 +188,7 @@
 		{
 			name:     "preformatted remove built-in",
 			replace:  removeKeys(TimeKey, LevelKey, MessageKey),
-			with:     func(h Handler) Handler { return h.With(preAttrs) },
+			with:     func(h Handler) Handler { return h.WithAttrs(preAttrs) },
 			attrs:    attrs,
 			wantText: "pre=3 x=y a=one b=2",
 			wantJSON: `{"pre":3,"x":"y","a":"one","b":2}`,
@@ -240,7 +240,7 @@
 		{
 			name:     "with-group",
 			replace:  removeKeys(TimeKey, LevelKey),
-			with:     func(h Handler) Handler { return h.With(preAttrs).WithGroup("s") },
+			with:     func(h Handler) Handler { return h.WithAttrs(preAttrs).WithGroup("s") },
 			attrs:    attrs,
 			wantText: "msg=message pre=3 x=y s·a=one s·b=2",
 			wantJSON: `{"msg":"message","pre":3,"x":"y","s":{"a":"one","b":2}}`,
@@ -249,9 +249,9 @@
 			name:    "preformatted with-groups",
 			replace: removeKeys(TimeKey, LevelKey),
 			with: func(h Handler) Handler {
-				return h.With([]Attr{Int("p1", 1)}).
+				return h.WithAttrs([]Attr{Int("p1", 1)}).
 					WithGroup("s1").
-					With([]Attr{Int("p2", 2)}).
+					WithAttrs([]Attr{Int("p2", 2)}).
 					WithGroup("s2")
 			},
 			attrs:    attrs,
@@ -262,7 +262,7 @@
 			name:    "two with-groups",
 			replace: removeKeys(TimeKey, LevelKey),
 			with: func(h Handler) Handler {
-				return h.With([]Attr{Int("p1", 1)}).
+				return h.WithAttrs([]Attr{Int("p1", 1)}).
 					WithGroup("s1").
 					WithGroup("s2")
 			},
diff --git a/slog/json_handler.go b/slog/json_handler.go
index 66e36c6..0475034 100644
--- a/slog/json_handler.go
+++ b/slog/json_handler.go
@@ -48,7 +48,7 @@
 
 // With returns a new JSONHandler whose attributes consists
 // of h's attributes followed by attrs.
-func (h *JSONHandler) With(attrs []Attr) Handler {
+func (h *JSONHandler) WithAttrs(attrs []Attr) Handler {
 	return &JSONHandler{commonHandler: h.commonHandler.withAttrs(attrs)}
 }
 
diff --git a/slog/logger.go b/slog/logger.go
index 87b0ba6..b956fa8 100644
--- a/slog/logger.go
+++ b/slog/logger.go
@@ -89,7 +89,7 @@
 		attr, args = argsToAttr(args)
 		attrs = append(attrs, attr)
 	}
-	l.handler = l.handler.With(attrs)
+	l.handler = l.handler.WithAttrs(attrs)
 	return l
 }
 
diff --git a/slog/logger_test.go b/slog/logger_test.go
index f857e1b..3f3faab 100644
--- a/slog/logger_test.go
+++ b/slog/logger_test.go
@@ -307,7 +307,7 @@
 
 func (*captureHandler) Enabled(Level) bool { return true }
 
-func (c *captureHandler) With(as []Attr) Handler {
+func (c *captureHandler) WithAttrs(as []Attr) Handler {
 	c2 := *c
 	c2.attrs = concat(c2.attrs, as)
 	return &c2
@@ -324,7 +324,7 @@
 
 func (d discardHandler) Enabled(Level) bool { return !d.disabled }
 func (discardHandler) Handle(Record) error  { return nil }
-func (d discardHandler) With(as []Attr) Handler {
+func (d discardHandler) WithAttrs(as []Attr) Handler {
 	d.attrs = concat(d.attrs, as)
 	return d
 }
diff --git a/slog/text_handler.go b/slog/text_handler.go
index bd482f4..5f66b24 100644
--- a/slog/text_handler.go
+++ b/slog/text_handler.go
@@ -43,7 +43,7 @@
 
 // With returns a new TextHandler whose attributes consists
 // of h's attributes followed by attrs.
-func (h *TextHandler) With(attrs []Attr) Handler {
+func (h *TextHandler) WithAttrs(attrs []Attr) Handler {
 	return &TextHandler{commonHandler: h.commonHandler.withAttrs(attrs)}
 }
 
diff --git a/slog/text_handler_test.go b/slog/text_handler_test.go
index 22326a0..2e4dcc2 100644
--- a/slog/text_handler_test.go
+++ b/slog/text_handler_test.go
@@ -140,7 +140,7 @@
 func TestTextHandlerPreformatted(t *testing.T) {
 	var buf bytes.Buffer
 	var h Handler = NewTextHandler(&buf)
-	h = h.With([]Attr{Duration("dur", time.Minute), Bool("b", true)})
+	h = h.WithAttrs([]Attr{Duration("dur", time.Minute), Bool("b", true)})
 	// Also test omitting time.
 	r := NewRecord(time.Time{}, 0 /* 0 Level is INFO */, "m", 0, nil)
 	r.AddAttrs(Int("a", 1))