aboutsummaryrefslogtreecommitdiffstats
path: root/models/models.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-02-20 16:11:13 +0800
committerGitHub <noreply@github.com>2017-02-20 16:11:13 +0800
commit04fdeb9d8d4dc3cf296d8354ee29f1d053154a54 (patch)
treea0510e09bd7d5f91520fd101ad478cf3c8e2a623 /models/models.go
parentd4b752def9d46995720526c1757456948df2a790 (diff)
downloadgitea-04fdeb9d8d4dc3cf296d8354ee29f1d053154a54.tar.gz
gitea-04fdeb9d8d4dc3cf296d8354ee29f1d053154a54.zip
Make Xorm log configurable (#174)
* make xorm log configable * bug fixed for other sub commands except web * rebase and fix xorm log * bug fix for TrimSpace
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/models/models.go b/models/models.go
index 27b49755aa..33268fabbe 100644
--- a/models/models.go
+++ b/models/models.go
@@ -25,6 +25,7 @@ import (
_ "github.com/denisenkom/go-mssqldb"
"code.gitea.io/gitea/models/migrations"
+ "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
@@ -226,6 +227,7 @@ func getEngine() (*xorm.Engine, error) {
default:
return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type)
}
+
return xorm.NewEngine(DbCfg.Type, connStr)
}
@@ -236,6 +238,8 @@ func NewTestEngine(x *xorm.Engine) (err error) {
return fmt.Errorf("Connect to database: %v", err)
}
+ setting.NewXORMLogService(false)
+
x.SetMapper(core.GonicMapper{})
return x.StoreEngine("InnoDB").Sync2(tables...)
}
@@ -248,20 +252,9 @@ func SetEngine() (err error) {
}
x.SetMapper(core.GonicMapper{})
-
// WARNING: for serv command, MUST remove the output to os.stdout,
// so use log file to instead print to stdout.
- logPath := path.Join(setting.LogRootPath, "xorm.log")
-
- if err := os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
- return fmt.Errorf("Failed to create dir %s: %v", logPath, err)
- }
-
- f, err := os.Create(logPath)
- if err != nil {
- return fmt.Errorf("Failed to create xorm.log: %v", err)
- }
- x.SetLogger(xorm.NewSimpleLogger(f))
+ x.SetLogger(log.XORMLogger)
x.ShowSQL(true)
return nil
}