diff --git a/web/context.go b/web/context.go index 16d4117da2..e4b5c8d084 100644 --- a/web/context.go +++ b/web/context.go @@ -87,22 +87,21 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) { func (c *Context) LogErrorByCode(err *model.AppError) { code := err.StatusCode - var level mlog.LogLevel - switch { - case (code >= http.StatusBadRequest && code < http.StatusInternalServerError) || - err.Id == "web.check_browser_compatibility.app_error": - level = mlog.LvlDebug - case code == http.StatusNotImplemented: - level = mlog.LvlInfo - default: - level = mlog.LvlError - } - c.Logger.Log(level, - err.SystemMessage(utils.TDefault), + msg := err.SystemMessage(utils.TDefault) + fields := []mlog.Field{ mlog.String("err_where", err.Where), mlog.Int("http_code", err.StatusCode), mlog.String("err_details", err.DetailedError), - ) + } + switch { + case (code >= http.StatusBadRequest && code < http.StatusInternalServerError) || + err.Id == "web.check_browser_compatibility.app_error": + c.Logger.Debug(msg, fields...) + case code == http.StatusNotImplemented: + c.Logger.Info(msg, fields...) + default: + c.Logger.Error(msg, fields...) + } } func (c *Context) IsSystemAdmin() bool {