Documentation
¶
Overview ¶
Package logging provides an slog.Handler that fans a record out to several handlers, each with its own independent level filter. It exists so cargoship can write every log level to a file for later debugging while the terminal keeps showing only what the user's configured --log-level asks for.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenFileHandler ¶
OpenFileHandler opens (creating if needed) the file at path and returns an slog.Handler that writes every level -- Debug and up, i.e. all of them -- to it as JSON. The caller owns the returned file and must close it once logging is done.
Types ¶
type MultiHandler ¶
type MultiHandler struct {
// contains filtered or unexported fields
}
MultiHandler dispatches each log record to every handler that wants it. Unlike wrapping a single slog.Logger, each handler keeps its own Enabled check: one handler can be silent at Info while another still records everything down to Debug.
func NewMultiHandler ¶
func NewMultiHandler(handlers ...slog.Handler) *MultiHandler
NewMultiHandler returns a MultiHandler that fans records out to handlers.
func (*MultiHandler) Enabled ¶
Enabled reports whether at least one handler wants records at level. This must stay a logical OR: the top-level slog.Logger calls Enabled before Handle, so if this returned false whenever any single handler would refuse the level, that handler would silence every other handler in the group along with it -- including a file handler meant to catch everything.
func (*MultiHandler) Handle ¶
Handle passes r to every handler whose own Enabled check accepts r.Level.