Commit 086b5948 by Torkel Ödegaard

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

parent 1584dac0
......@@ -22,6 +22,7 @@ var loggersToClose []DisposableHandler
func init() {
loggersToClose = make([]DisposableHandler, 0)
Root = log15.Root()
Root.SetHandler(log15.DiscardHandler())
}
func New(logger string, ctx ...interface{}) Logger {
......
......@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"gopkg.in/macaron.v1"
......@@ -35,10 +34,8 @@ func QuotaReached(c *Context, target string) (bool, error) {
return false, err
}
log.Debug(fmt.Sprintf("checking quota for %s in scopes %v", target, scopes))
for _, scope := range scopes {
log.Debug(fmt.Sprintf("checking scope %s", scope.Name))
c.Logger.Debug("Checking quota", "target", target, "scope", scope)
switch scope.Name {
case "global":
......@@ -51,7 +48,7 @@ func QuotaReached(c *Context, target string) (bool, error) {
if target == "session" {
usedSessions := getSessionCount()
if int64(usedSessions) > scope.DefaultLimit {
log.Debug(fmt.Sprintf("%d sessions active, limit is %d", usedSessions, scope.DefaultLimit))
c.Logger.Debug("Sessions limit reached", "active", usedSessions, "limit", scope.DefaultLimit)
return true, nil
}
continue
......
......@@ -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)
}
}
......
......@@ -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()
......
......@@ -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 {
......
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment