logging

package
v0.300.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 5

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) Debug

func (d *Deduper) Debug(msg string, args ...any)

Debug logs the provided message and key-value arguments using the Deduper's internal slog.Logger. It is simply a wrapper around slog.Logger.Debug().

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) Error

func (d *Deduper) Error(msg string, args ...any)

Error logs the provided message and key-value arguments using the Deduper's internal slog.Logger. It is simply a wrapper around slog.Logger.Error().

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) Info

func (d *Deduper) Info(msg string, args ...any)

Info logs the provided message and key-value arguments using the Deduper's internal slog.Logger. It is simply a wrapper around slog.Logger.Info().

func (*Deduper) Stop

func (d *Deduper) Stop()

Stop the Deduper.

func (*Deduper) Warn

func (d *Deduper) Warn(msg string, args ...any)

Warn logs the provided message and key-value arguments using the Deduper's internal slog.Logger. It is simply a wrapper around slog.Logger.Warn().

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) Debug added in v0.300.0

func (l *JSONFileLogger) Debug(msg string, args ...any)

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

func (*JSONFileLogger) Error added in v0.300.0

func (l *JSONFileLogger) Error(msg string, args ...any)

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

func (*JSONFileLogger) Info added in v0.300.0

func (l *JSONFileLogger) Info(msg string, args ...any)

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

func (*JSONFileLogger) Warn added in v0.300.0

func (l *JSONFileLogger) Warn(msg string, args ...any)

Warn calls the `Warn()` 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