Documentation
¶
Overview ¶
Package logger provides a structured slog-based logger.
Log entries are sent to two destinations:
- BrowserHandler: serialises records to JSON and pushes them into a channel consumed by the realtime module (centrifuge → browser console).
- os.Stderr: only for Fatal/Error level so the operator sees critical issues without opening a browser.
Index ¶
- type BrowserHandler
- func (h *BrowserHandler) Chan() <-chan []byte
- func (h *BrowserHandler) Enabled(_ context.Context, l slog.Level) bool
- func (h *BrowserHandler) Handle(_ context.Context, r slog.Record) error
- func (h *BrowserHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *BrowserHandler) WithGroup(name string) slog.Handler
- type LogEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrowserHandler ¶
type BrowserHandler struct {
// contains filtered or unexported fields
}
BrowserHandler implements slog.Handler and pushes JSON-encoded LogEntry values into a buffered channel for consumption by the realtime module.
func New ¶
New builds a *slog.Logger and the associated BrowserHandler.
The logger fans out to:
- BrowserHandler (all levels >= cfg.Level) → centrifuge channel
- slog.TextHandler on stderr (Error+ only) → terminal for fatal cases
func (*BrowserHandler) Chan ¶
func (h *BrowserHandler) Chan() <-chan []byte
Chan returns the read-only channel of JSON-encoded log entries. The realtime module drains this channel and publishes to centrifuge.
Click to show internal directories.
Click to hide internal directories.