[NOD-330] Use BTCD logs for gorm (#410)

This commit is contained in:
Ori Newman 2019-09-18 11:47:54 +03:00 committed by Svarog
parent e81ac5f19e
commit f4850b9e7a
2 changed files with 17 additions and 0 deletions

View File

@ -23,6 +23,13 @@ func DB() (*gorm.DB, error) {
return db, nil
}
type gormLogger struct{}
func (l gormLogger) Print(v ...interface{}) {
str := fmt.Sprint(v...)
log.Errorf(str)
}
// Connect connects to the database mentioned in
// config variable.
func Connect(cfg *config.Config) error {
@ -40,6 +47,7 @@ func Connect(cfg *config.Config) error {
if err != nil {
return err
}
db.SetLogger(gormLogger{})
return nil
}

View File

@ -0,0 +1,9 @@
package database
import "github.com/daglabs/btcd/util/panics"
import "github.com/daglabs/btcd/apiserver/logger"
var (
log = logger.BackendLog.Logger("DTBS")
spawn = panics.GoroutineWrapperFunc(log, logger.BackendLog)
)