diff options
-rw-r--r-- | conf/app.ini | 2 | ||||
-rw-r--r-- | models/models.go | 10 | ||||
-rw-r--r-- | update.go | 24 |
3 files changed, 23 insertions, 13 deletions
diff --git a/conf/app.ini b/conf/app.ini index abc27c39c4..bb620d4741 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -32,7 +32,7 @@ PATH = data/gogs.db [admin] [security] -INSTALL_LOCK = false +INSTALL_LOCK = true ; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! SECRET_KEY = !#@FDEWREWR&*( ; Auto-login remember days diff --git a/models/models.go b/models/models.go index a626b98f6e..384f1fc425 100644 --- a/models/models.go +++ b/models/models.go @@ -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 } @@ -6,17 +6,19 @@ package main import ( "container/list" + "fmt" "os" "os/exec" + "path" "strconv" "strings" "github.com/codegangsta/cli" - //"github.com/gogits/gogs/modules/log" "github.com/gogits/git" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" - "github.com/qiniu/log" + "github.com/gogits/gogs/modules/log" + //"github.com/qiniu/log" ) var CmdUpdate = cli.Command{ @@ -28,25 +30,29 @@ gogs serv provide access auth for repositories`, Flags: []cli.Flag{}, } +func newUpdateLogger(execDir string) { + level := "0" + logPath := execDir + "/log/update.log" + os.MkdirAll(path.Dir(logPath), os.ModePerm) + log.NewLogger(0, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, logPath)) + log.Trace("start logging...") +} + // for command: ./gogs update func runUpdate(c *cli.Context) { + execDir, _ := base.ExecDir() + newLogger(execDir) + base.NewConfigContext() models.LoadModelsConfig() if models.UseSQLite3 { - execDir, _ := base.ExecDir() os.Chdir(execDir) } models.SetEngine() - w, _ := os.Create("update.log") - defer w.Close() - - log.SetOutput(w) - args := c.Args() - //log.Info(args) if len(args) != 3 { log.Error("received less 3 parameters") return |