summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorMartin Kraft <mkraft@users.noreply.github.com>2017-11-23 09:44:56 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-11-23 09:44:56 -0500
commit942b5b5cc045ce06712fc5868b299f7f082a7276 (patch)
treec0ea964f628bf1d71f9192daffd2b0752189b654 /api4
parentbbb301b7de636c211df8aa5b304e543d4d136637 (diff)
downloadchat-942b5b5cc045ce06712fc5868b299f7f082a7276.tar.gz
chat-942b5b5cc045ce06712fc5868b299f7f082a7276.tar.bz2
chat-942b5b5cc045ce06712fc5868b299f7f082a7276.zip
PLT-8058: Logging api.context.invalid_session.error app errors to log level 'info'. (#7893)
Diffstat (limited to 'api4')
-rw-r--r--api4/context.go15
1 files changed, 13 insertions, 2 deletions
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)