mirror of
https://github.com/astaxie/beego.git
synced 2025-02-16 21:17:04 +00:00
record the critical logs in Prod
This commit is contained in:
parent
21586586ba
commit
364cacf659
57
router.go
57
router.go
@ -857,48 +857,29 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) {
|
|||||||
if err == USERSTOPRUN {
|
if err == USERSTOPRUN {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if RunMode == "dev" {
|
if !RecoverPanic {
|
||||||
if !RecoverPanic {
|
panic(err)
|
||||||
panic(err)
|
|
||||||
} else {
|
|
||||||
if ErrorsShow {
|
|
||||||
if _, ok := ErrorMaps[fmt.Sprint(err)]; ok {
|
|
||||||
exception(fmt.Sprint(err), context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var stack string
|
|
||||||
Critical("the request url is ", context.Input.Url())
|
|
||||||
Critical("Handler crashed with error", err)
|
|
||||||
for i := 1; ; i++ {
|
|
||||||
_, file, line, ok := runtime.Caller(i)
|
|
||||||
if !ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
Critical(fmt.Sprintf("%s:%d", file, line))
|
|
||||||
stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line))
|
|
||||||
}
|
|
||||||
showErr(err, context, stack)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if !RecoverPanic {
|
if ErrorsShow {
|
||||||
panic(err)
|
if _, ok := ErrorMaps[fmt.Sprint(err)]; ok {
|
||||||
} else {
|
|
||||||
// in production model show all infomation
|
|
||||||
if ErrorsShow {
|
|
||||||
exception(fmt.Sprint(err), context)
|
exception(fmt.Sprint(err), context)
|
||||||
} else {
|
return
|
||||||
Critical("the request url is ", context.Input.Url())
|
|
||||||
Critical("Handler crashed with error", err)
|
|
||||||
for i := 1; ; i++ {
|
|
||||||
_, file, line, ok := runtime.Caller(i)
|
|
||||||
if !ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
Critical(fmt.Sprintf("%s:%d", file, line))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var stack string
|
||||||
|
Critical("the request url is ", context.Input.Url())
|
||||||
|
Critical("Handler crashed with error", err)
|
||||||
|
for i := 1; ; i++ {
|
||||||
|
_, file, line, ok := runtime.Caller(i)
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
Critical(fmt.Sprintf("%s:%d", file, line))
|
||||||
|
stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line))
|
||||||
|
}
|
||||||
|
if RunMode == "dev" {
|
||||||
|
showErr(err, context, stack)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user