Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexlast/bunzap
A query hook for uptrace/bun that logs with uber-go/zap.
https://github.com/alexlast/bunzap
bun zap
Last synced: 25 days ago
JSON representation
A query hook for uptrace/bun that logs with uber-go/zap.
- Host: GitHub
- URL: https://github.com/alexlast/bunzap
- Owner: AlexLast
- Created: 2023-05-12T07:33:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-02T19:38:47.000Z (2 months ago)
- Last Synced: 2024-09-29T05:21:36.095Z (about 1 month ago)
- Topics: bun, zap
- Language: Go
- Homepage:
- Size: 47.9 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bunzap
A query hook for [uptrace/bun](https://github.com/uptrace/bun) that logs with [uber-go/zap](https://github.com/uber-go/zap).```bash
$ go get github.com/alexlast/bunzap
```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()
logger, err := zap.NewProduction()
db.AddQueryHook(bunzap.NewQueryHook(bunzap.QueryHookOptions{
Logger: logger,
SlowDuration: 200 * time.Millisecond, // Omit to log all operations as debug
}))
```