Documentation
¶
Overview ¶
Package logger provides structured logging utilities.
Index ¶
Constants ¶
const ( LevelDebugExtra = slog.Level(-8) LevelExtreme = slog.Level(-12) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Enricher ¶
type Enricher struct {
// contains filtered or unexported fields
}
Enricher injects GCP metadata in the record attributes.
func NewEnricher ¶
NewEnricher wraps the provided slog.Handler. It injects GCP Cloud Logging compatible trace fields extracted from the context if a valid span is present.
func (*Enricher) Enabled ¶
Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower.
func (*Enricher) Handle ¶
Handle adds the trace ID, span ID, and sampled flag to the record attributes.
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter logs record to GCP Cloud Logging API.
func NewExporter ¶
NewExporter creates an slog.Handler that directly logs to GCP Cloud logging.
type MultiHandler ¶
type MultiHandler struct {
// contains filtered or unexported fields
}
MultiHandler is a Exporter that invokes all the given Handlers. Its Enabled method reports whether any of the handlers' Enabled methods return true. Its Handle, WithAttrs and WithGroup methods call the corresponding method on each of the enabled handlers. Copied from slog. TODO: Move to slog.MultiHandler once the project has moved to go 1.26
func NewMultiHandler ¶
func NewMultiHandler(handlers ...slog.Handler) *MultiHandler
NewMultiHandler creates a MultiHandler with the given Handlers.