logger

package
v0.0.0-...-031a617 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IsPg          bool
	LogLevel      = Debug
	SlowThreshold = 1 * time.Second
)

Functions

func ExplainSQL

func ExplainSQL(sql string, avars ...interface{}) string

func GetLogger

func GetLogger(ctx context.Context) *zerolog.Logger

GetLogger retrieves the logger from the context

func InitLogger

func InitLogger() *zerolog.Logger

InitLogger initializes and returns a zerolog logger

func PrintSQL

func PrintSQL(ctx context.Context, rowsAffected *int64, err error, cost time.Duration, query string, args ...interface{})

PrintSQL logs the SQL execution details including the query, arguments, execution time, affected rows, and any errors.

func SafeGo

func SafeGo(fn func())

SafeGo runs the given function in a new goroutine and recovers from any panic, logging the error and stack trace.

func SetDefaultLevel

func SetDefaultLevel(level Level)

func SetGlobalLogger

func SetGlobalLogger(log *zerolog.Logger)

SetGlobalLogger sets the global logger

func SetIsPg

func SetIsPg(dbType string)

SetIsPg sets the IsPg variable based on the provided dbType string.

func SetLevel

func SetLevel(ctx context.Context, level Level) context.Context

Types

type Level

type Level uint8
const (
	Debug Level = iota + 1
	Info
	Off
)

type LevelKey

type LevelKey struct{}

Jump to

Keyboard shortcuts

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