logging

package
v0.300.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

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 Dedupe

func Dedupe(next *slog.Logger, repeat time.Duration) *Deduper

Dedupe log lines to next, only repeating every repeat duration.

func (*Deduper) Enabled added in v0.300.0

func (d *Deduper) Enabled(ctx context.Context, level slog.Level) bool

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

func (d *Deduper) Handle(ctx context.Context, r slog.Record) error

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.

func (*Deduper) Stop

func (d *Deduper) Stop()

Stop the Deduper.

func (*Deduper) WithAttrs added in v0.300.0

func (d *Deduper) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs adds the provided attributes to the Deduper's internal slog.Logger. It implements slog.Handler.

func (*Deduper) WithGroup added in v0.300.0

func (d *Deduper) WithGroup(name string) slog.Handler

WithGroup adds the provided group name to the Deduper's internal slog.Logger. It implements slog.Handler.

type JSONFileLogger

type JSONFileLogger struct {
	// contains filtered or unexported fields
}

JSONFileLogger represents a logger that writes JSON to a file. It implements the promql.QueryLogger 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 promql.QueryLogger interface.

func (*JSONFileLogger) Log

func (l *JSONFileLogger) Log(ctx context.Context, level slog.Level, msg string, args ...any)

Log calls the `Log()` method on the underlying `log/slog.Logger` with the provided msg and args. It implements the promql.QueryLogger interface.

func (*JSONFileLogger) With added in v0.300.0

func (l *JSONFileLogger) With(args ...any)

With calls the `With()` method on the underlying `log/slog.Logger` with the provided msg and args. It implements the promql.QueryLogger interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL