diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-19 04:48:45 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-19 04:48:45 -0400 |
commit | bd9d90d8c48965e4e78fd56147c465ba80ec5ed5 (patch) | |
tree | e523e7db6eec1af33bb920680d24bacd64d8c588 /modules | |
parent | b192b70aecbe3b91affd9d9396669ed000a936d6 (diff) | |
download | gitea-bd9d90d8c48965e4e78fd56147c465ba80ec5ed5.tar.gz gitea-bd9d90d8c48965e4e78fd56147c465ba80ec5ed5.zip |
Add some log
Diffstat (limited to 'modules')
-rw-r--r-- | modules/base/conf.go | 7 | ||||
-rw-r--r-- | modules/middleware/context.go | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go index 6610bce1ab..9f6de56b9d 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -10,6 +10,7 @@ import ( "os/exec" "path" "path/filepath" + "strings" "github.com/Unknwon/com" "github.com/Unknwon/goconfig" @@ -63,9 +64,10 @@ func newLogService() { } // Log level. - level, ok := logLevels[Cfg.MustValue("log."+mode, "LEVEL", "Trace")] + levelName := Cfg.MustValue("log."+mode, "LEVEL", "Trace") + level, ok := logLevels[levelName] if !ok { - fmt.Printf("Unknown log level: %s\n", Cfg.MustValue("log."+mode, "LEVEL", "Trace")) + fmt.Printf("Unknown log level: %s\n", levelName) os.Exit(2) } @@ -99,6 +101,7 @@ func newLogService() { } log.NewLogger(Cfg.MustInt64("log", "BUFFER_LEN", 10000), mode, config) + log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName) } func newMailService() { diff --git a/modules/middleware/context.go b/modules/middleware/context.go index d002d3c24e..7eaf665005 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -67,8 +67,13 @@ func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) { // Handle handles and logs error by given status. func (ctx *Context) Handle(status int, title string, err error) { - ctx.Data["ErrorMsg"] = err log.Error("%s: %v", title, err) + if martini.Dev == martini.Prod { + ctx.Render.HTML(500, "status/500", ctx.Data) + return + } + + ctx.Data["ErrorMsg"] = err ctx.Render.HTML(status, fmt.Sprintf("status/%d", status), ctx.Data) } |