mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-19 16:30:15 +00:00
Add router log config option
This commit is contained in:
parent
03c2468c2f
commit
100cd181bc
8 changed files with 32 additions and 9 deletions
|
@ -106,11 +106,19 @@ 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) {
|
||||
log.Error("%s: %v", title, err)
|
||||
if martini.Dev != martini.Prod {
|
||||
ctx.Data["ErrorMsg"] = err
|
||||
if err != nil {
|
||||
log.Error("%s: %v", title, err)
|
||||
if martini.Dev != martini.Prod {
|
||||
ctx.Data["ErrorMsg"] = err
|
||||
}
|
||||
}
|
||||
|
||||
switch status {
|
||||
case 404:
|
||||
ctx.Data["Title"] = "Page Not Found"
|
||||
case 500:
|
||||
ctx.Data["Title"] = "Internal Server Error"
|
||||
}
|
||||
ctx.HTML(status, fmt.Sprintf("status/%d", status))
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-martini/martini"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
)
|
||||
|
||||
var isWindows bool
|
||||
|
@ -22,6 +24,10 @@ func init() {
|
|||
|
||||
func Logger() martini.Handler {
|
||||
return func(res http.ResponseWriter, req *http.Request, ctx martini.Context, log *log.Logger) {
|
||||
if !base.RouterLog {
|
||||
return
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
log.Printf("Started %s %s", req.Method, req.URL.Path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue