Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.
/ logs-go-gorm Public archive

Logging package for gorm based on logs-go wrapper

License

Notifications You must be signed in to change notification settings

microparts/logs-go-gorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo is DEPRECATED! Use https://github.com/spacetab-io/logs-gorm-go instead.

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.

About

Logging package for gorm based on logs-go wrapper

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages