]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/log/slog/example_wrap_test.go
log/slog: add Source type for source location
[gostls13.git] / src / log / slog / example_wrap_test.go
index b96de11320c67f35350e1928f41f16dc2dfb5b72..d422517b6e1556d8dc84dd9a329378ba74c35d92 100644 (file)
@@ -34,7 +34,8 @@ func Example_wrapping() {
                }
                // Remove the directory from the source's filename.
                if a.Key == slog.SourceKey {
-                       a.Value = slog.StringValue(filepath.Base(a.Value.String()))
+                       source := a.Value.Any().(*slog.Source)
+                       source.File = filepath.Base(source.File)
                }
                return a
        }
@@ -42,5 +43,5 @@ func Example_wrapping() {
        Infof(logger, "message, %s", "formatted")
 
        // Output:
-       // level=INFO source=example_wrap_test.go:42 msg="message, formatted"
+       // level=INFO source=example_wrap_test.go:43 msg="message, formatted"
 }