sqlog

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 3 Imported by: 0

README

Slog SQL Logger

// open a database connection with sql logging support
db, err := sqlog.Open("mysql", "root:pass@tcp(localhost:3309)")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(driverName, dsn string, opt ...Options) (*sql.DB, error)

Open opens a database specified by its database driver name and a driver-specific data source name with logging support.

Types

type Options

type Options interface {
	// contains filtered or unexported methods
}

Options is a function that can be applied to a Logger.

func WithBaseLevel

func WithBaseLevel(level slog.Level) Options

WithBaseLevel set the base level.

func WithLogger

func WithLogger(log *slog.Logger) Options

WithLogger set the logger.

func WithPrefix

func WithPrefix(prefix string) Options

WithPrefix set the prefix.

func WithStmtPrefix

func WithStmtPrefix(prefix string) Options

WithStmtPrefix set the statement prefix.

func WithTxPrefix

func WithTxPrefix(prefix string) Options

WithTxPrefix set the transaction prefix.

func WithWarnErrSkip added in v0.2.0

func WithWarnErrSkip() Options

WithWarnErrSkip log driver.ErrSkip error as warning.

func WithoutDuration

func WithoutDuration() Options

WithoutDuration disable log duration output.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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