improved log locations

This commit is contained in:
Lunny Xiao 2014-03-31 21:26:15 +08:00
parent 76c64b43cb
commit a187ba9651
3 changed files with 23 additions and 13 deletions

View file

@ -83,15 +83,19 @@ func SetEngine() (err error) {
// WARNNING: for serv command, MUST remove the output to os.stdout,
// so use log file to instead print to stdout.
execDir, _ := base.ExecDir()
logPath := execDir + "/log/xorm.log"
os.MkdirAll(path.Dir(logPath), os.ModePerm)
//x.ShowDebug = true
//orm.ShowErr = true
f, err := os.Create("xorm.log")
f, err := os.Create(logPath)
if err != nil {
return fmt.Errorf("models.init(fail to create xorm.log): %v\n", err)
}
orm.Logger = f
orm.ShowSQL = true
orm.ShowDebug = true
orm.ShowErr = true
return nil
}