https://github.com/alexlast/bunmicro
A query hook for uptrace/bun that logs with go-micro/logger.
https://github.com/alexlast/bunmicro
Last synced: about 1 month ago
JSON representation
A query hook for uptrace/bun that logs with go-micro/logger.
- Host: GitHub
- URL: https://github.com/alexlast/bunmicro
- Owner: AlexLast
- Created: 2023-08-30T09:24:20.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T01:42:38.000Z (over 1 year ago)
- Last Synced: 2025-01-05T19:12:05.725Z (over 1 year ago)
- Language: Go
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bunmicro
A query hook for [uptrace/bun](https://github.com/uptrace/bun) that logs with [go-micro/logger](https://github.com/go-micro/go-micro/tree/master/logger).
```bash
$ 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
```go
db := bun.NewDB()
db.AddQueryHook(bunmicro.NewQueryHook(bunmicro.QueryHookOptions{
Logger: logger.DefaultLogger,
SlowDuration: 200 * time.Millisecond, // Omit to log all operations as debug
}))
```