log: return TerminalHandler write errors from Handle (#35055)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

Propagate slog Handle failures when the underlying io.Writer rejects
output.
This commit is contained in:
cui 2026-05-28 00:27:35 +08:00 committed by GitHub
parent f4a90d178a
commit ab20d50dba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,9 +77,9 @@ func (h *TerminalHandler) Handle(_ context.Context, r slog.Record) error {
h.mu.Lock() h.mu.Lock()
defer h.mu.Unlock() defer h.mu.Unlock()
buf := h.format(h.buf, r, h.useColor) buf := h.format(h.buf, r, h.useColor)
h.wr.Write(buf) _, err := h.wr.Write(buf)
h.buf = buf[:0] h.buf = buf[:0]
return nil return err
} }
func (h *TerminalHandler) Enabled(_ context.Context, level slog.Level) bool { func (h *TerminalHandler) Enabled(_ context.Context, level slog.Level) bool {