Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 15 for withAttrs (0.16 sec)

  1. src/log/slog/handler_test.go

    			wantJSON: `{"g":{"n":4,"h":{"i":{"c":3}}}}`,
    		},
    		{
    			name: "replace partial empty attrs 3",
    			with: func(h Handler) Handler {
    				return h.WithGroup("g").WithAttrs([]Attr{Int("x", 0)}).WithAttrs([]Attr{Int("a", 1)}).WithAttrs([]Attr{Int("n", 4)}).WithGroup("h").WithAttrs([]Attr{Int("b", 2)})
    			},
    			replace: func(groups []string, attr Attr) Attr {
    				return removeKeys(TimeKey, LevelKey, MessageKey, "a", "c")(groups, attr)
    			},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 02 13:57:53 UTC 2023
    - 19.6K bytes
    - Viewed (0)
  2. src/testing/slogtest/slogtest.go

    		},
    	},
    	{
    		name:        "resolve-WithAttrs",
    		explanation: withSource("a Handler should call Resolve on attribute values from WithAttrs"),
    		f: func(l *slog.Logger) {
    			l = l.With("k", &replace{"replaced"})
    			l.Info("msg")
    		},
    		checks: []check{hasAttr("k", "replaced")},
    	},
    	{
    		name:        "resolve-WithAttrs-groups",
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Nov 08 17:55:47 UTC 2023
    - 9.8K bytes
    - Viewed (0)
  3. src/log/slog/example_level_handler_test.go

    func (h *LevelHandler) Handle(ctx context.Context, r slog.Record) error {
    	return h.handler.Handle(ctx, r)
    }
    
    // WithAttrs implements Handler.WithAttrs.
    func (h *LevelHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
    	return NewLevelHandler(h.level, h.handler.WithAttrs(attrs))
    }
    
    // WithGroup implements Handler.WithGroup.
    func (h *LevelHandler) WithGroup(name string) slog.Handler {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 04 18:32:54 UTC 2023
    - 2.2K bytes
    - Viewed (0)
  4. src/log/slog/internal/benchmarks/handlers.go

    		panic(fmt.Sprintf("bad kind: %s", v.Kind()))
    	}
    }
    
    func (h *fastTextHandler) appendTime(buf *buffer.Buffer, t time.Time) {
    	*buf = strconv.AppendInt(*buf, t.Unix(), 10)
    }
    
    func (h *fastTextHandler) WithAttrs([]slog.Attr) slog.Handler {
    	panic("fastTextHandler: With unimplemented")
    }
    
    func (*fastTextHandler) WithGroup(string) slog.Handler {
    	panic("fastTextHandler: WithGroup unimplemented")
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Apr 12 20:33:37 UTC 2023
    - 4.1K bytes
    - Viewed (0)
  5. src/log/slog/text_handler.go

    func (h *TextHandler) Enabled(_ context.Context, level Level) bool {
    	return h.commonHandler.enabled(level)
    }
    
    // WithAttrs returns a new [TextHandler] whose attributes consists
    // of h's attributes followed by attrs.
    func (h *TextHandler) WithAttrs(attrs []Attr) Handler {
    	return &TextHandler{commonHandler: h.commonHandler.withAttrs(attrs)}
    }
    
    func (h *TextHandler) WithGroup(name string) Handler {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 23 22:56:07 UTC 2023
    - 4.7K bytes
    - Viewed (0)
  6. src/log/slog/json_handler.go

    func (h *JSONHandler) Enabled(_ context.Context, level Level) bool {
    	return h.commonHandler.enabled(level)
    }
    
    // WithAttrs returns a new [JSONHandler] whose attributes consists
    // of h's attributes followed by attrs.
    func (h *JSONHandler) WithAttrs(attrs []Attr) Handler {
    	return &JSONHandler{commonHandler: h.commonHandler.withAttrs(attrs)}
    }
    
    func (h *JSONHandler) WithGroup(name string) Handler {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 17 16:18:11 UTC 2023
    - 8.1K bytes
    - Viewed (0)
  7. src/log/slog/handler.go

    	//   - If a group has no Attrs (even if it has a non-empty key),
    	//     ignore it.
    	Handle(context.Context, Record) error
    
    	// WithAttrs returns a new Handler whose attributes consist of
    	// both the receiver's attributes and the arguments.
    	// The Handler owns the slice: it may retain, modify or discard it.
    	WithAttrs(attrs []Attr) Handler
    
    	// WithGroup returns a new Handler with the given group appended to
    	// the receiver's existing groups.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Dec 05 18:18:13 UTC 2023
    - 17.5K bytes
    - Viewed (0)
  8. src/log/slog/logger_test.go

    	return h.h.Enabled(ctx, level)
    }
    func (h wrappingHandler) WithGroup(name string) Handler              { return h.h.WithGroup(name) }
    func (h wrappingHandler) WithAttrs(as []Attr) Handler                { return h.h.WithAttrs(as) }
    func (h wrappingHandler) Handle(ctx context.Context, r Record) error { return h.h.Handle(ctx, r) }
    
    func TestAttrs(t *testing.T) {
    	check := func(got []Attr, want ...Attr) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 10 21:25:30 UTC 2023
    - 19.5K bytes
    - Viewed (0)
  9. src/log/slog/text_handler_test.go

    	}
    	return []byte(fmt.Sprintf("text{%q}", t.s)), nil
    }
    
    func TestTextHandlerPreformatted(t *testing.T) {
    	var buf bytes.Buffer
    	var h Handler = NewTextHandler(&buf, nil)
    	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)
    	r.AddAttrs(Int("a", 1))
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 22 19:05:59 UTC 2023
    - 3.8K bytes
    - Viewed (0)
  10. api/go1.21.txt

    pkg log/slog, type Handler interface, Enabled(context.Context, Level) bool #56345
    pkg log/slog, type Handler interface { Enabled, Handle, WithAttrs, WithGroup } #56345
    pkg log/slog, type Handler interface, Handle(context.Context, Record) error #56345
    pkg log/slog, type Handler interface, WithAttrs([]Attr) Handler #56345
    pkg log/slog, type Handler interface, WithGroup(string) Handler #56345
    pkg log/slog, type HandlerOptions struct #56345
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Aug 07 09:39:17 UTC 2023
    - 25.6K bytes
    - Viewed (0)
Back to top