From cfc501f5a647e0b0bab9d7ddfb68ef049d893009 Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Fri, 8 Jan 2021 23:15:17 +0300 Subject: [PATCH] [MM-31776] explicitly call level functions for mlog (#16648) Automatic Merge --- web/context.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) 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 {