record the critical logs in Prod
Showing
1 changed file
with
19 additions
and
38 deletions
| ... | @@ -857,47 +857,28 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) { | ... | @@ -857,47 +857,28 @@ 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" { | 860 | if !RecoverPanic { |
| 861 | if !RecoverPanic { | 861 | panic(err) |
| 862 | panic(err) | ||
| 863 | } else { | ||
| 864 | if ErrorsShow { | ||
| 865 | if _, ok := ErrorMaps[fmt.Sprint(err)]; ok { | ||
| 866 | exception(fmt.Sprint(err), context) | ||
| 867 | return | ||
| 868 | } | ||
| 869 | } | ||
| 870 | var stack string | ||
| 871 | Critical("the request url is ", context.Input.Url()) | ||
| 872 | Critical("Handler crashed with error", err) | ||
| 873 | for i := 1; ; i++ { | ||
| 874 | _, file, line, ok := runtime.Caller(i) | ||
| 875 | if !ok { | ||
| 876 | break | ||
| 877 | } | ||
| 878 | Critical(fmt.Sprintf("%s:%d", file, line)) | ||
| 879 | stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)) | ||
| 880 | } | ||
| 881 | showErr(err, context, stack) | ||
| 882 | } | ||
| 883 | } else { | 862 | } else { |
| 884 | if !RecoverPanic { | 863 | if ErrorsShow { |
| 885 | panic(err) | 864 | if _, ok := ErrorMaps[fmt.Sprint(err)]; ok { |
| 886 | } else { | ||
| 887 | // in production model show all infomation | ||
| 888 | if ErrorsShow { | ||
| 889 | exception(fmt.Sprint(err), context) | 865 | exception(fmt.Sprint(err), context) |
| 890 | } else { | 866 | return |
| 891 | Critical("the request url is ", context.Input.Url()) | 867 | } |
| 892 | Critical("Handler crashed with error", err) | 868 | } |
| 893 | for i := 1; ; i++ { | 869 | var stack string |
| 894 | _, file, line, ok := runtime.Caller(i) | 870 | Critical("the request url is ", context.Input.Url()) |
| 895 | if !ok { | 871 | Critical("Handler crashed with error", err) |
| 896 | break | 872 | for i := 1; ; i++ { |
| 897 | } | 873 | _, file, line, ok := runtime.Caller(i) |
| 898 | Critical(fmt.Sprintf("%s:%d", file, line)) | 874 | if !ok { |
| 899 | } | 875 | break |
| 900 | } | 876 | } |
| 877 | Critical(fmt.Sprintf("%s:%d", file, line)) | ||
| 878 | stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)) | ||
| 879 | } | ||
| 880 | if RunMode == "dev" { | ||
| 881 | showErr(err, context, stack) | ||
| 901 | } | 882 | } |
| 902 | } | 883 | } |
| 903 | } | 884 | } | ... | ... |
-
Please register or sign in to post a comment