Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for ExampleLogValuer_secret (0.26 sec)

  1. src/log/slog/example_logvaluer_secret_test.go

    func (Token) LogValue() slog.Value {
    	return slog.StringValue("REDACTED_TOKEN")
    }
    
    // This example demonstrates a Value that replaces itself
    // with an alternative representation to avoid revealing secrets.
    func ExampleLogValuer_secret() {
    	t := Token("shhhh!")
    	logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ReplaceAttr: slogtest.RemoveTime}))
    	logger.Info("permission granted", "user", "Perry", "token", t)
    
    	// Output:
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 04 18:32:54 UTC 2023
    - 906 bytes
    - Viewed (0)
Back to top