]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/log/slog/handler_test.go
log/slog: built-in handler constructors take options as a second arg
[gostls13.git] / src / log / slog / handler_test.go
index 7b5aac303cde00fe67602be6d697e8e1d589944c..fee611cf6af6d9dea680793194f3f47e10fa762a 100644 (file)
@@ -338,8 +338,8 @@ func TestJSONAndTextHandlers(t *testing.T) {
                                h    Handler
                                want string
                        }{
-                               {"text", opts.NewTextHandler(&buf), test.wantText},
-                               {"json", opts.NewJSONHandler(&buf), test.wantJSON},
+                               {"text", NewTextHandler(&buf, &opts), test.wantText},
+                               {"json", NewJSONHandler(&buf, &opts), test.wantJSON},
                        } {
                                t.Run(handler.name, func(t *testing.T) {
                                        h := handler.h
@@ -419,7 +419,7 @@ func TestSecondWith(t *testing.T) {
        // Verify that a second call to Logger.With does not corrupt
        // the original.
        var buf bytes.Buffer
-       h := HandlerOptions{ReplaceAttr: removeKeys(TimeKey)}.NewTextHandler(&buf)
+       h := NewTextHandler(&buf, &HandlerOptions{ReplaceAttr: removeKeys(TimeKey)})
        logger := New(h).With(
                String("app", "playground"),
                String("role", "tester"),
@@ -445,14 +445,14 @@ func TestReplaceAttrGroups(t *testing.T) {
 
        var got []ga
 
-       h := HandlerOptions{ReplaceAttr: func(gs []string, a Attr) Attr {
+       h := NewTextHandler(io.Discard, &HandlerOptions{ReplaceAttr: func(gs []string, a Attr) Attr {
                v := a.Value.String()
                if a.Key == TimeKey {
                        v = "<now>"
                }
                got = append(got, ga{strings.Join(gs, ","), a.Key, v})
                return a
-       }}.NewTextHandler(io.Discard)
+       }})
        New(h).
                With(Int("a", 1)).
                WithGroup("g1").