log

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextLoggerBuilder added in v1.6.0

type ContextLoggerBuilder interface {
	Build(ctx context.Context) Logger
}

ContextLoggerBuilder produces a Logger bound to a request context.

type Hook

type Hook struct {
	*Options
}

Hook is an otsql.Hook that emits an access log entry after every SQL event.

func New

func New(opts ...Option) *Hook

func (*Hook) After

func (hook *Hook) After(ctx context.Context, evt *otsql.Event)

func (*Hook) Before

func (hook *Hook) Before(ctx context.Context, evt *otsql.Event) context.Context

type Level added in v1.6.0

type Level int

Level is the log level used to dispatch a log entry to one of the Logger methods.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelError
)

type Logger

type Logger interface {
	Debug(message string, args ...any)
	Info(message string, args ...any)
	Error(message string, args ...any)
	WithFields(fields ...any) Logger
}

Logger is the minimal logging interface required by the hook. It is intentionally implementation-agnostic: args are flat key/value tuples (k1, v1, k2, v2, ...).

type Option

type Option func(*Options)

Option configures a Hook.

func WithArgs

func WithArgs(b bool) Option

func WithDefaultLevel

func WithDefaultLevel(level Level) Option

func WithLogger

func WithLogger(builder ContextLoggerBuilder) Option

WithLogger installs a ContextLoggerBuilder together with the default level to use when a method has no explicit override. Both arguments are required: it is impossible to install a logger without choosing a default level.

func WithMethodLevel

func WithMethodLevel(method otsql.Method, level Level) Option

func WithQuery

func WithQuery(b bool) Option

func WithSlow

func WithSlow(d time.Duration) Option

type Options

type Options struct {
	Builder      ContextLoggerBuilder
	DefaultLevel Level
	MethodLevels map[otsql.Method]Level

	Slow time.Duration

	Query bool
	Args  bool
}

Options is the resolved configuration of a Hook.

Jump to

Keyboard shortcuts

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