gormzerolog

package module
v0.0.0-...-9ec213b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 6 Imported by: 0

README

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/Ahmet-Kaplan/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))

	// ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func New

func New(l *zerolog.Logger) Logger

func (Logger) Error

func (l Logger) Error(ctx context.Context, msg string, opts ...interface{})

func (Logger) Info

func (l Logger) Info(ctx context.Context, msg string, opts ...interface{})

func (Logger) LogMode

func (l Logger) LogMode(logger.LogLevel) logger.Interface

func (Logger) Trace

func (l Logger) Trace(ctx context.Context, begin time.Time, f func() (string, int64), err error)

func (Logger) Warn

func (l Logger) Warn(ctx context.Context, msg string, opts ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL