gormlogruslogger

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

README

go-gorm-logrus-logger

A simple logger implementation for GORM, using logrus for the actual logging.

Usage

package main

import (
	"context"

	"github.com/aklinkert/go-gorm-logrus-logger"
	"github.com/sirupsen/logrus"
	"gorm.io/gorm"
)

func main() {
	logger := logrus.New()

	// initialize your DB Connection
	var dial gorm.Dialector

	db, err := gorm.Open(dial, &gorm.Config{
		Logger: gormlogruslogger.NewGormLogrusLogger(logger.WithField("component", "gorm")),
	})

	if err != nil {
		logger.Fatalf("failed to open DB connection: %v", err)
	}

	var _ = db
}

License

Apache 2.0 Licence

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGormLogrusLogger

func NewGormLogrusLogger(logger *logrus.Entry, slowLogThreshold time.Duration) logger.Interface

NewGormLogrusLogger returns a new gorm/logger.Interface compliant logger that uses logrus for the actual logging

Types

This section is empty.

Jump to

Keyboard shortcuts

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