From 942b5b5cc045ce06712fc5868b299f7f082a7276 Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Thu, 23 Nov 2017 09:44:56 -0500 Subject: PLT-8058: Logging api.context.invalid_session.error app errors to log level 'info'. (#7893) --- api4/context.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'api4/context.go') diff --git a/api4/context.go b/api4/context.go index bf9794e4c..832b12414 100644 --- a/api4/context.go +++ b/api4/context.go @@ -148,7 +148,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { session, err := c.App.GetSession(token) if err != nil { - l4g.Error(utils.T("api.context.invalid_session.error"), err.Error()) + l4g.Info(utils.T("api.context.invalid_session.error"), err.Error()) c.RemoveSessionCookie(w, r) if h.requireSession { c.Err = model.NewAppError("ServeHTTP", "api.context.session_expired.app_error", nil, "token="+token, http.StatusUnauthorized) @@ -178,7 +178,13 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if c.Err != nil { c.Err.Translate(c.T) c.Err.RequestId = c.RequestId - c.LogError(c.Err) + + if c.Err.Id == "api.context.session_expired.app_error" { + c.LogInfo(c.Err) + } else { + c.LogError(c.Err) + } + c.Err.Where = r.URL.Path // Block out detailed error when not in developer mode @@ -234,6 +240,11 @@ func (c *Context) LogError(err *model.AppError) { } } +func (c *Context) LogInfo(err *model.AppError) { + l4g.Info(utils.TDefault("api.context.log.error"), c.Path, err.Where, err.StatusCode, + c.RequestId, c.Session.UserId, c.IpAddress, err.SystemMessage(utils.TDefault), err.DetailedError) +} + func (c *Context) LogDebug(err *model.AppError) { l4g.Debug(utils.TDefault("api.context.log.error"), c.Path, err.Where, err.StatusCode, c.RequestId, c.Session.UserId, c.IpAddress, err.SystemMessage(utils.TDefault), err.DetailedError) -- cgit v1.2.3-1-g7c22