Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 11 for TimeKey (0.19 sec)

  1. src/log/slog/handler_test.go

    			wantText: "",
    			wantJSON: "{}",
    		},
    		{
    			name:     "remove built-in",
    			replace:  removeKeys(TimeKey, LevelKey, MessageKey),
    			attrs:    attrs,
    			wantText: "a=one b=2",
    			wantJSON: `{"a":"one","b":2}`,
    		},
    		{
    			name:     "preformatted remove built-in",
    			replace:  removeKeys(TimeKey, LevelKey, MessageKey),
    			with:     func(h Handler) Handler { return h.WithAttrs(preAttrs) },
    			attrs:    attrs,
    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

    	checks []check
    }
    
    var cases = []testCase{
    	{
    		name:        "built-ins",
    		explanation: withSource("this test expects slog.TimeKey, slog.LevelKey and slog.MessageKey"),
    		f: func(l *slog.Logger) {
    			l.Info("message")
    		},
    		checks: []check{
    			hasKey(slog.TimeKey),
    			hasKey(slog.LevelKey),
    			hasAttr(slog.MessageKey, "message"),
    		},
    	},
    	{
    		name:        "attrs",
    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/internal/slogtest/slogtest.go

    // RemoveTime removes the top-level time attribute.
    // It is intended to be used as a ReplaceAttr function,
    // to make example output deterministic.
    func RemoveTime(groups []string, a slog.Attr) slog.Attr {
    	if a.Key == slog.TimeKey && len(groups) == 0 {
    		return slog.Attr{}
    	}
    	return a
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Apr 12 20:33:11 UTC 2023
    - 553 bytes
    - Viewed (0)
  4. src/log/slog/example_test.go

    	r, _ := http.NewRequest("GET", "localhost", nil)
    	// ...
    
    	logger := slog.New(
    		slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
    			ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
    				if a.Key == slog.TimeKey && len(groups) == 0 {
    					return slog.Attr{}
    				}
    				return a
    			},
    		}),
    	)
    	logger.Info("finished",
    		slog.Group("req",
    			slog.String("method", r.Method),
    			slog.String("url", r.URL.String())),
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 17 14:56:30 UTC 2023
    - 857 bytes
    - Viewed (0)
  5. src/log/slog/example_wrap_test.go

    	_ = logger.Handler().Handle(context.Background(), r)
    }
    
    func Example_wrapping() {
    	replace := func(groups []string, a slog.Attr) slog.Attr {
    		// Remove time.
    		if a.Key == slog.TimeKey && len(groups) == 0 {
    			return slog.Attr{}
    		}
    		// Remove the directory from the source's filename.
    		if a.Key == slog.SourceKey {
    			source := a.Value.Any().(*slog.Source)
    			source.File = filepath.Base(source.File)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 04 18:32:54 UTC 2023
    - 1.3K bytes
    - Viewed (0)
  6. src/log/slog/example_custom_levels_test.go

    		// LevelInfo, which would drop Debug and Trace logs.
    		Level: LevelTrace,
    
    		ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
    			// Remove time from the output for predictable test output.
    			if a.Key == slog.TimeKey {
    				return slog.Attr{}
    			}
    
    			// Customize the name of the level key and the output string, including
    			// custom level values.
    			if a.Key == slog.LevelKey {
    				// Rename the level key from "level" to "sev".
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jul 11 17:06:26 UTC 2023
    - 3K bytes
    - Viewed (0)
  7. src/log/slog/handler.go

    	// remove attributes from the output.
    	ReplaceAttr func(groups []string, a Attr) Attr
    }
    
    // Keys for "built-in" attributes.
    const (
    	// TimeKey is the key used by the built-in handlers for the time
    	// when the log method is called. The associated Value is a [time.Time].
    	TimeKey = "time"
    	// LevelKey is the key used by the built-in handlers for the level
    	// of the log call. The associated value is a [Level].
    	LevelKey = "level"
    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. pkg/log/config.go

    	InfoLevel:  zapcore.InfoLevel,
    	WarnLevel:  zapcore.WarnLevel,
    	ErrorLevel: zapcore.ErrorLevel,
    	FatalLevel: zapcore.FatalLevel,
    	NoneLevel:  none,
    }
    
    var defaultEncoderConfig = zapcore.EncoderConfig{
    	TimeKey:        "time",
    	LevelKey:       "level",
    	NameKey:        "scope",
    	CallerKey:      "caller",
    	MessageKey:     "msg",
    	StacktraceKey:  "stack",
    	LineEnding:     zapcore.DefaultLineEnding,
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Tue Mar 26 20:38:10 UTC 2024
    - 12.1K bytes
    - Viewed (0)
  9. src/log/slog/logger_test.go

    		logBuf.Reset()
    	}
    }
    
    // Test handlerWriter minimum level by calling slog.SetDefault.
    func TestLogLoggerLevelForHandlerWriter(t *testing.T) {
    	removeTime := func(_ []string, a Attr) Attr {
    		if a.Key == TimeKey {
    			return Attr{}
    		}
    		return a
    	}
    
    	// Revert any changes to the default logger. This is important because other
    	// tests might change the default logger using SetDefault. Also ensure we
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 10 21:25:30 UTC 2023
    - 19.5K bytes
    - Viewed (0)
  10. api/go1.21.txt

    pkg log/slog, const MessageKey = "msg" #56345
    pkg log/slog, const SourceKey ideal-string #56345
    pkg log/slog, const SourceKey = "source" #56345
    pkg log/slog, const TimeKey ideal-string #56345
    pkg log/slog, const TimeKey = "time" #56345
    pkg log/slog, func Any(string, interface{}) Attr #56345
    pkg log/slog, func AnyValue(interface{}) Value #56345
    pkg log/slog, func Bool(string, bool) Attr #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