writeError writes a logging error message to STDERR.
(err error)
| 210 | |
| 211 | // writeError writes a logging error message to STDERR. |
| 212 | func (h *Handler) writeError(err error) { |
| 213 | buf := newBuffer() |
| 214 | defer func() { |
| 215 | buf.free() |
| 216 | }() |
| 217 | |
| 218 | r := slog.NewRecord(time.Now(), slog.LevelError, "An error occurred during logging", 0) |
| 219 | r.Add("error", err) |
| 220 | |
| 221 | h.format(r, buf) |
| 222 | |
| 223 | _, _ = os.Stderr.Write(*buf) |
| 224 | } |
| 225 | |
| 226 | // withGroup returns a new handler with the given attribute group added. |
| 227 | func (h *Handler) withGroup(group attrGroup) *Handler { |