Categorygithub.com/alexlast/bunmicro
repositorypackage
0.0.0-20240611151013-fde75f3ec2fb
Repository: https://github.com/alexlast/bunmicro.git
Documentation: pkg.go.dev

# README

bunmicro

A query hook for uptrace/bun that logs with go-micro/logger.

$ go get github.com/alexlast/bunmicro

All errors will be logged at error level with the hook enabled, everything else will be logged as debug. If SlowDuration is defined, only operations taking longer than the defined duration will be logged.

Usage

db := bun.NewDB()
db.AddQueryHook(bunmicro.NewQueryHook(bunmicro.QueryHookOptions{
    Logger:       logger.DefaultLogger,
    SlowDuration: 200 * time.Millisecond, // Omit to log all operations as debug
}))