Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 8 of 8 for LogAttrs (0.12 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/internal/benchmarks/benchmarks_test.go

    					"5 args",
    					func() {
    						logger.LogAttrs(nil, slog.LevelInfo, testMessage,
    							slog.String("string", testString),
    							slog.Int("status", testInt),
    							slog.Duration("duration", testDuration),
    							slog.Time("time", testTime),
    							slog.Any("error", testError),
    						)
    					},
    				},
    				{
    					"5 args ctx",
    					func() {
    						logger.LogAttrs(ctx, slog.LevelInfo, testMessage,
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 04 18:32:54 UTC 2023
    - 4.5K bytes
    - Viewed (0)
  4. src/log/slog/json_handler_test.go

    				String("package", "log/slog"),
    				String("traceID", "2039232309232309"),
    				String("URL", "https://pkg.go.dev/golang.org/x/log/slog"))
    			b.ReportAllocs()
    			b.ResetTimer()
    			for i := 0; i < b.N; i++ {
    				l.LogAttrs(ctx, LevelInfo, "this is a typical log message",
    					String("module", "github.com/google/go-cmp"),
    					String("version", "v1.23.4"),
    					Int("count", 23),
    					Int("number", 123456),
    				)
    			}
    		})
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jul 11 17:06:26 UTC 2023
    - 6.5K bytes
    - Viewed (0)
  5. 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)
  6. 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)
  7. 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)
  8. src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go

    		{"(*Logger).ErrorContext", Method, 21},
    		{"(*Logger).Handler", Method, 21},
    		{"(*Logger).Info", Method, 21},
    		{"(*Logger).InfoContext", Method, 21},
    		{"(*Logger).Log", Method, 21},
    		{"(*Logger).LogAttrs", Method, 21},
    		{"(*Logger).Warn", Method, 21},
    		{"(*Logger).WarnContext", Method, 21},
    		{"(*Logger).With", Method, 21},
    		{"(*Logger).WithGroup", Method, 21},
    		{"(*Record).Add", Method, 21},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 534.2K bytes
    - Viewed (0)
Back to top