Documentation
¶
Overview ¶
Package logx provides a tiny, thread-safe holder for an injected logger.Logger. It exists so each capability can expose a SetLogger/GetLogger pair that defaults to a no-op without re-implementing the atomic swap logic.
The logger is optional: until one is injected, Slot.Get returns logger.NopLogger, which discards everything. A minimal build that never constructs a logger therefore pays nothing beyond the no-op calls.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Slot ¶
type Slot struct {
// contains filtered or unexported fields
}
Slot is a lock-free holder for an optional logger. The zero value is ready to use and reports a no-op logger until Slot.Set is called. A Slot must not be copied after first use.
func (*Slot) Get ¶
Get returns the active logger, or logger.NopLogger if none has been set. Get never returns nil and is safe for concurrent use.