record the critical logs in Prod
Showing
1 changed file
with
1 additions
and
20 deletions
| ... | @@ -857,7 +857,6 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) { | ... | @@ -857,7 +857,6 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) { |
| 857 | if err == USERSTOPRUN { | 857 | if err == USERSTOPRUN { |
| 858 | return | 858 | return |
| 859 | } | 859 | } |
| 860 | if RunMode == "dev" { | ||
| 861 | if !RecoverPanic { | 860 | if !RecoverPanic { |
| 862 | panic(err) | 861 | panic(err) |
| 863 | } else { | 862 | } else { |
| ... | @@ -878,27 +877,9 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) { | ... | @@ -878,27 +877,9 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) { |
| 878 | Critical(fmt.Sprintf("%s:%d", file, line)) | 877 | Critical(fmt.Sprintf("%s:%d", file, line)) |
| 879 | stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)) | 878 | stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)) |
| 880 | } | 879 | } |
| 880 | if RunMode == "dev" { | ||
| 881 | showErr(err, context, stack) | 881 | showErr(err, context, stack) |
| 882 | } | 882 | } |
| 883 | } else { | ||
| 884 | if !RecoverPanic { | ||
| 885 | panic(err) | ||
| 886 | } else { | ||
| 887 | // in production model show all infomation | ||
| 888 | if ErrorsShow { | ||
| 889 | exception(fmt.Sprint(err), context) | ||
| 890 | } else { | ||
| 891 | Critical("the request url is ", context.Input.Url()) | ||
| 892 | Critical("Handler crashed with error", err) | ||
| 893 | for i := 1; ; i++ { | ||
| 894 | _, file, line, ok := runtime.Caller(i) | ||
| 895 | if !ok { | ||
| 896 | break | ||
| 897 | } | ||
| 898 | Critical(fmt.Sprintf("%s:%d", file, line)) | ||
| 899 | } | ||
| 900 | } | ||
| 901 | } | ||
| 902 | } | 883 | } |
| 903 | } | 884 | } |
| 904 | } | 885 | } | ... | ... |
-
Please register or sign in to post a comment