/gorm-zerolog

Alternative logging with Zerolog for GORM ⚡️

Primary LanguageGoMIT LicenseMIT

gorm-zerolog

Build Status codecov GoDoc license

Alternative logging with zerolog for GORM ⚡️

In comparison to gorm's default logger, gorm-zerolog is faster, reflection free, low allocations and no regex compilations.

Example

package main

import (
	"github.com/jinzhu/gorm"
	"github.com/gorpher/gorm-zerolog"
)

const (
	databaseURL = "postgres://postgres:@localhost/gormzr?sslmode=disable"
)

func main() {
	logger, err = zerolog.NewProduction()
	if err != nil {
		panic(err)
	}

	db, err := gorm.Open("postgres", databaseURL)
	if err != nil {
		panic(err)
	}
	db.LogMode(true)
	db.SetLogger(gorm - zerolog.New(logger))

	// ...
}