Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hypnoglow/gormzap
GORM (v1) logger implementation using Uber's zap :zap:
https://github.com/hypnoglow/gormzap
golang gorm logging structured-logging zap
Last synced: 3 months ago
JSON representation
GORM (v1) logger implementation using Uber's zap :zap:
- Host: GitHub
- URL: https://github.com/hypnoglow/gormzap
- Owner: hypnoglow
- License: mit
- Created: 2018-04-20T13:38:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-14T12:23:54.000Z (over 6 years ago)
- Last Synced: 2024-10-30T09:36:23.076Z (3 months ago)
- Topics: golang, gorm, logging, structured-logging, zap
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 14
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gormzap
[![GoDoc](https://godoc.org/github.com/hypnoglow/gormzap?status.svg)](https://godoc.org/github.com/hypnoglow/gormzap)
[![CircleCI](https://circleci.com/gh/hypnoglow/gormzap.svg?style=shield)](https://circleci.com/gh/hypnoglow/gormzap)
[![GitHub release](https://img.shields.io/github/tag/hypnoglow/gormzap.svg)](https://github.com/hypnoglow/gormzap/releases)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)[GORM](https://github.com/jinzhu/gorm) logger implementation using [zap](https://github.com/uber-go/zap).
## Usage
```go
var debug bool // shows if we have debug enabled in our appdb, err := gorm.Open("postgres", dsn)
if err != nil {
panic(err)
}if debug {
// By default, gorm logs only errors. If we set LogMode to true,
// then all queries will be logged.
// WARNING: if you explicitly set this to false, then even
// errors won't be logged.
db.LogMode(true)
}log := zap.NewExample()
db.SetLogger(gormzap.New(log, gormzap.WithLevel(zap.DebugLevel)))
```