Help us shape the future of Go! Take the 2026 Go Developer Survey

gormLogger

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: MIT Imports: 1 Imported by: 0

README

logs-go-gorm

Logger fo gorm

Usage

Initiate new logger with prefilled logs.Config and use it to initiate new gorm logger

package main

import (
	"time"
	
  "github.com/jinzhu/gorm"
	"github.com/microparts/logs-go"
	"github.com/microparts/logs-go-gorm"
)

func main() {
	// initiate logs-go
	conf := &logs.Config{
		Level:"warn",
		Format: "text",
		Sentry: &logs.SentryConfig{
			Enable: true,
			Stage:"test",
			DSN: "http://dsn.sentry.com",
			ResponseTimeout: 0,
			StackTrace: logs.StackTraceConfig{
				Enable: true,
			},
		},
	}
	
	l, err := logs.NewLogger(conf)
	if err != nil {
		panic(err)
	}
	
	db, _ := gorm.Open("sqlite3", "./db.sqlite")
  db.SetLogger(gormLogger.NewLogger(l))
  db.LogMode(true)
}

Licence

The software is provided under MIT Licence.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormLogger

type GormLogger struct {
	*logrus.Logger
}

func NewLogger

func NewLogger(logger *logrus.Logger) *GormLogger

NewLogger initiates new gorm logger

func (*GormLogger) Print

func (d *GormLogger) Print(v ...interface{})

Print format & print log

Jump to

Keyboard shortcuts

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