logger

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelTrace = LogLevel(6)
	LogLevelDebug = LogLevel(5)
	LogLevelInfo  = LogLevel(4)
	LogLevelWarn  = LogLevel(3)
	LogLevelError = LogLevel(2)
	LogLevelNone  = LogLevel(1)
)

The values for log levels are chosen such that the zero value means that no log level was specified.

Variables

This section is empty.

Functions

func LogQueryArgs

func LogQueryArgs(args []any) []any

Types

type Func

type Func func(ctx context.Context, level LogLevel, msg string, data map[string]interface{})

Func is a wrapper around a function to satisfy the pgx.Logger interface

func (Func) Log

func (f Func) Log(ctx context.Context, level LogLevel, msg string, data map[string]interface{})

Log delegates the logging request to the wrapped function

type LogLevel

type LogLevel int

LogLevel represents the pgx logging level. See LogLevel* constants for possible values.

func LogLevelFromString

func LogLevelFromString(s string) (LogLevel, error)

LogLevelFromString converts log level string to constant

Valid levels:

trace
debug
info
warn
error
none

func (LogLevel) String

func (ll LogLevel) String() string

type Logger

type Logger interface {
	// Log a message at the given level with data key/value pairs. data may be nil.
	Log(ctx context.Context, level LogLevel, msg string, data map[string]any)
}

Logger is the interface used to get log output from pgx.

func NewLogger

func NewLogger(l *logrus.Logger) Logger

Jump to

Keyboard shortcuts

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