log

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogHook

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

LogHook is a hook.Hook implementation for SQL logging.

func NewLogHook

func NewLogHook(options ...LogHookOption) *LogHook

NewLogHook returns a new LogHook, for a provided list of LogHookOption.

func (*LogHook) After

func (h *LogHook) After(ctx context.Context, event *sql.HookEvent)

After executes SQL logging logic after SQL operations.

func (*LogHook) Before

func (h *LogHook) Before(ctx context.Context, _ *sql.HookEvent) context.Context

Before executes SQL logging logic before SQL operations.

type LogHookOption

type LogHookOption func(o *Options)

LogHookOption are the functional options for LogHook.

func WithArguments

func WithArguments(arguments bool) LogHookOption

WithArguments is used to enable the SQL arguments logging.

func WithExcludedOperations

func WithExcludedOperations(excludedOperations ...sql.Operation) LogHookOption

WithExcludedOperations is used to exclude a list of SQL operations from logging.

func WithLevel

func WithLevel(level zerolog.Level) LogHookOption

WithLevel is used to configure the SQL logging level.

type Options

type Options struct {
	Level              zerolog.Level
	Arguments          bool
	ExcludedOperations []sql.Operation
}

Options are the options for LogHook.

func DefaultLogHookOptions

func DefaultLogHookOptions() Options

DefaultLogHookOptions are the default options for LogHook.

Jump to

Keyboard shortcuts

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