feat(loggin): disable logging by default so unit tests are not full of logging

This commit is contained in:
Torkel Ödegaard
2016-06-11 11:38:25 +02:00
parent 1584dac00a
commit 086b59483e
6 changed files with 7 additions and 13 deletions

View File

@@ -12,8 +12,6 @@ import (
)
func InitTestDB(t *testing.T) {
t.Log("InitTestDB")
x, err := xorm.NewEngine(sqlutil.TestDB_Sqlite3.DriverName, sqlutil.TestDB_Sqlite3.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Mysql.DriverName, sqlutil.TestDB_Mysql.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Postgres.DriverName, sqlutil.TestDB_Postgres.ConnStr)
@@ -24,7 +22,7 @@ func InitTestDB(t *testing.T) {
sqlutil.CleanDB(x)
if err := SetEngine(x, false); err != nil {
if err := SetEngine(x); err != nil {
t.Fatal(err)
}
}

View File

@@ -6,7 +6,6 @@ import (
"github.com/go-xorm/xorm"
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/inconshreveable/log15"
. "github.com/smartystreets/goconvey/convey"
)
@@ -29,7 +28,6 @@ func TestMigrations(t *testing.T) {
sqlutil.CleanDB(x)
mg := NewMigrator(x)
mg.Logger.SetHandler(log15.DiscardHandler())
AddMigrations(mg)
err = mg.Start()

View File

@@ -107,7 +107,7 @@ func (mg *Migrator) Start() error {
}
func (mg *Migrator) exec(m Migration) error {
log.Info("Executing migration", "id", m.Id())
mg.Logger.Info("Executing migration", "id", m.Id())
err := mg.inTransaction(func(sess *xorm.Session) error {

View File

@@ -78,7 +78,7 @@ func NewEngine() {
os.Exit(1)
}
err = SetEngine(x, setting.Env == setting.DEV)
err = SetEngine(x)
if err != nil {
sqlog.Error("Fail to initialize orm engine", "error", err)
@@ -86,7 +86,7 @@ func NewEngine() {
}
}
func SetEngine(engine *xorm.Engine, enableLog bool) (err error) {
func SetEngine(engine *xorm.Engine) (err error) {
x = engine
dialect = migrator.NewDialect(x.DriverName())