diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-31 21:26:15 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-31 21:26:15 +0800 |
commit | a187ba96512a49ac7888d87960657ab6ee369a50 (patch) | |
tree | bf38225add4f9c9437cb67709ac138ac40994479 /update.go | |
parent | 76c64b43cb56a298e5fc2ec8adc0d7b820cbe614 (diff) | |
download | gitea-a187ba96512a49ac7888d87960657ab6ee369a50.tar.gz gitea-a187ba96512a49ac7888d87960657ab6ee369a50.zip |
improved log locations
Diffstat (limited to 'update.go')
-rw-r--r-- | update.go | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -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 |