Documentation
¶
Overview ¶
Package handler provides a buffered slog.Handler implementation that transforms log records and writes them to a provided store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffered ¶
type Buffered[T any] struct { // contains filtered or unexported fields }
Buffered is a slog.Handler that buffers log records by transforming them and writing them to a provided store. It is useful for scenarios where logs need to be collected and processed in batches, for example, before sending them to an external service or database.
func NewBuffered ¶
func NewBuffered[T any](transform Transform[T], store store.Store[T], options ...Option) *Buffered[T]
NewBuffered creates and returns a new Buffered handler.
The transform function is used to convert an slog.Record into the specific type T before it is written to the store.
The store is where the transformed logs will be written. It must implement the store.Store[T] interface.
func (*Buffered[T]) Enabled ¶
Enabled reports whether the handler will log a record with the given level.