Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for LogAttrs (0.09 sec)

  1. src/log/slog/logger.go

    func Log(ctx context.Context, level Level, msg string, args ...any) {
    	Default().log(ctx, level, msg, args...)
    }
    
    // LogAttrs calls [Logger.LogAttrs] on the default logger.
    func LogAttrs(ctx context.Context, level Level, msg string, attrs ...Attr) {
    	Default().logAttrs(ctx, level, msg, attrs...)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jan 08 18:26:18 UTC 2024
    - 10.2K bytes
    - Viewed (0)
  2. src/log/slog/logger_test.go

    	})
    	t.Run("attrs1", func(t *testing.T) {
    		wantAllocs(t, 0, func() { dl.LogAttrs(ctx, LevelInfo, "", Int("a", 1)) })
    		wantAllocs(t, 0, func() { dl.LogAttrs(ctx, LevelInfo, "", Any("error", io.EOF)) })
    	})
    	t.Run("attrs3", func(t *testing.T) {
    		wantAllocs(t, 0, func() {
    			dl.LogAttrs(ctx, LevelInfo, "hello", Int("a", 1), String("b", "two"), Duration("c", time.Second))
    		})
    	})
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 10 21:25:30 UTC 2023
    - 19.5K bytes
    - Viewed (0)
  3. src/log/slog/doc.go

    without an allocation.
    
    For the most efficient log output, use [Logger.LogAttrs].
    It is similar to [Logger.Log] but accepts only Attrs, not alternating
    keys and values; this allows it, too, to avoid allocation.
    
    The call
    
    	logger.LogAttrs(ctx, slog.LevelInfo, "hello", slog.Int("count", 3))
    
    is the most efficient way to achieve the same output as
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 15 14:35:48 UTC 2024
    - 12.3K bytes
    - Viewed (0)
  4. src/log/slog/handler.go

    	//
    	// A Handler should treat WithGroup as starting a Group of Attrs that ends
    	// at the end of the log event. That is,
    	//
    	//     logger.WithGroup("s").LogAttrs(ctx, level, msg, slog.Int("a", 1), slog.Int("b", 2))
    	//
    	// should behave like
    	//
    	//     logger.LogAttrs(ctx, level, msg, slog.Group("s", slog.Int("a", 1), slog.Int("b", 2)))
    	//
    	// If the name is empty, WithGroup returns the receiver.
    	WithGroup(name string) Handler
    }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Dec 05 18:18:13 UTC 2023
    - 17.5K bytes
    - Viewed (0)
  5. api/go1.21.txt

    pkg log/slog, func Int64(string, int64) Attr #56345
    pkg log/slog, func Int64Value(int64) Value #56345
    pkg log/slog, func Int(string, int) Attr #56345
    pkg log/slog, func IntValue(int) Value #56345
    pkg log/slog, func LogAttrs(context.Context, Level, string, ...Attr) #56345
    pkg log/slog, func Log(context.Context, Level, string, ...interface{}) #56345
    pkg log/slog, func New(Handler) *Logger #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