Skip to content

Commit 075851b

Browse files
committed
adding example
1 parent 31bf660 commit 075851b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

example/example.go

+18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"time"
67

78
"log/slog"
89

@@ -124,7 +125,24 @@ func exampleFlatten() {
124125
Error("A message", "foo", "bar")
125126
}
126127

128+
func exampleTime() {
129+
logger := slog.New(
130+
slogmulti.
131+
Pipe(
132+
slogformatter.NewFormatterHandler(
133+
slogformatter.TimeFormatter(time.DateTime, time.UTC),
134+
),
135+
).
136+
Handler(slog.NewJSONHandler(os.Stdout, nil)),
137+
)
138+
139+
logger.
140+
With("time", time.Now()).
141+
Error("A message", "foo", "bar")
142+
}
143+
127144
func main() {
128145
example()
129146
exampleFlatten()
147+
exampleTime()
130148
}

0 commit comments

Comments
 (0)