Skip to content

Commit

Permalink
add a helpful comment
Browse files Browse the repository at this point in the history
  • Loading branch information
komuw committed May 26, 2023
1 parent 3db7a53 commit 6f54957
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ func New(w io.Writer, maxMsgs int) func(ctx context.Context) *slog.Logger {
AddSource: true,
Level: slog.LevelDebug,
}
jh := slog.NewJSONHandler(w, opts)
jh := slog.NewJSONHandler(
// os.Stderr is not buffered. Thus it will make a sycall for every write.
// os.Stdout on the other hand is buffered.
// https://eklitzke.org/stdout-buffering
w,
opts,
)
cbuf := newCirleBuf(maxMsgs)
hdlr := handler{wrappedHandler: jh, cBuf: cbuf, logID: id.New()}
l := slog.New(hdlr)
Expand Down

0 comments on commit 6f54957

Please sign in to comment.