tracelog

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger is an adapter for pgx tracelog to slog

func NewLogger

func NewLogger(logger *slog.Logger, opts ...LoggerOpt) *Logger

NewLogger builds a new logger instance given a slog.Logger instance

func (*Logger) Log

func (l *Logger) Log(ctx context.Context, level tracelog.LogLevel, msg string, data map[string]interface{})

Log a pgx log message to the underlying log instance, implements tracelog.Logger

type LoggerOpt

type LoggerOpt func(*Logger)

LoggerOpt sets options for the logger

func WithIgnoreErrors

func WithIgnoreErrors(matcher func(err error) bool) LoggerOpt

WithIgnoreErrors sets an option to ignore certain errors based on a matcher function

func WithRemapErrorLevel added in v0.4.0

func WithRemapErrorLevel(mapper func(tracelog.LogLevel, error) slog.Level) LoggerOpt

WithRemapErrorLevel sets a mapper function to conditionally remap log levels based on error inspection

func WithRemapLevel added in v0.2.1

func WithRemapLevel(in tracelog.LogLevel, out slog.Level) LoggerOpt

WithRemapLevel sets a mapping entry between pgx log levels and slog levels

Jump to

Keyboard shortcuts

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