Documentation
¶
Index ¶
- Constants
- func LogWithin(logger *slog.Logger, level slog.Level, timeout time.Duration, msg string, ...)
- func WarnWithin(logger *slog.Logger, timeout time.Duration, msg string, args ...any)
- func Within(timeout time.Duration, fn func())
- func WriteWithin(w io.Writer, timeout time.Duration, s string)
- type Logger
- type Option
Constants ¶
const LogBound = 100 * time.Millisecond
LogBound is what callers in this module pass: long enough for any handler that is working, short enough that one that is not cannot hold an exit.
Variables ¶
This section is empty.
Functions ¶
func LogWithin ¶ added in v0.30.0
func LogWithin(logger *slog.Logger, level slog.Level, timeout time.Duration, msg string, args ...any)
LogWithin logs at level under Within's bound. A nil logger logs nothing.
func WarnWithin ¶ added in v0.30.0
WarnWithin is LogWithin at Warn, the level every caller so far wants.
func Within ¶ added in v0.30.0
Within runs fn on its own goroutine and waits at most timeout for it. A bounded wait that ends with a diagnostic must not be made unbounded by the diagnostic: a log handler blocked on a stopped terminal, or a message written to that same terminal, would otherwise hold the caller exactly where the bound was meant to release it. Fire-and-forget would lose the line at process exit; waiting under a bound loses it only when it was never going to be written. The goroutine is abandoned on timeout.
Types ¶
type Logger ¶
Logger wraps slog.Logger with cleanup capability and dynamic handlers