Documentation
¶
Index ¶
- type Deduper
- type JSONFileLogger
- func (l *JSONFileLogger) Close() error
- func (l *JSONFileLogger) Enabled(ctx context.Context, level slog.Level) bool
- func (l *JSONFileLogger) Handle(ctx context.Context, r slog.Record) error
- func (l *JSONFileLogger) WithAttrs(attrs []slog.Attr) slog.Handler
- func (l *JSONFileLogger) WithGroup(name string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deduper ¶
type Deduper struct {
// contains filtered or unexported fields
}
Deduper implements *slog.Handler, dedupes log lines based on a time duration.
func (*Deduper) Enabled ¶ added in v0.300.0
Enabled returns true if the Deduper's internal slog.Logger is enabled at the provided context and log level, and returns false otherwise. It implements slog.Handler.
func (*Deduper) Handle ¶ added in v0.300.0
Handle uses the provided context and slog.Record to deduplicate messages every 1m. Log records received within the interval are not acted on, and thus dropped. Log records that pass deduplication and need action invoke the Handle() method on the Deduper's internal slog.Logger's handler, effectively chaining log calls to the internal slog.Logger.
type JSONFileLogger ¶
type JSONFileLogger struct {
// contains filtered or unexported fields
}
JSONFileLogger represents a logger that writes JSON to a file. It implements the slog.Handler interface, as well as the io.Closer interface.
func NewJSONFileLogger ¶
func NewJSONFileLogger(s string) (*JSONFileLogger, error)
NewJSONFileLogger returns a new JSONFileLogger.
func (*JSONFileLogger) Close ¶
func (l *JSONFileLogger) Close() error
Close closes the underlying file. It implements the io.Closer interface.
func (*JSONFileLogger) Enabled ¶
Enabled returns true if and only if the internal slog.Handler is enabled. It implements the slog.Handler interface.
func (*JSONFileLogger) Handle ¶
Handle takes record created by an slog.Logger and forwards it to the internal slog.Handler for dispatching the log call to the backing file. It implements the slog.Handler interface.