summaryrefslogtreecommitdiffstats
path: root/web/context.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-06-01 13:07:56 -0700
committerGitHub <noreply@github.com>2018-06-01 13:07:56 -0700
commitebdceb8e529810cd89599b8fbfda0157a659f3b5 (patch)
treef77f1bf8131006790b1792000bca1e06e7cd2211 /web/context.go
parent260d7a0f850a6f772b14b011022f1f65213a08a1 (diff)
downloadchat-ebdceb8e529810cd89599b8fbfda0157a659f3b5.tar.gz
chat-ebdceb8e529810cd89599b8fbfda0157a659f3b5.tar.bz2
chat-ebdceb8e529810cd89599b8fbfda0157a659f3b5.zip
Adding mlog to context. (#8882)
Diffstat (limited to 'web/context.go')
-rw-r--r--web/context.go26
1 files changed, 19 insertions, 7 deletions
diff --git a/web/context.go b/web/context.go
index 8f79421e5..7e4318233 100644
--- a/web/context.go
+++ b/web/context.go
@@ -4,7 +4,6 @@
package web
import (
- "fmt"
"net/http"
"regexp"
"strings"
@@ -19,6 +18,7 @@ import (
type Context struct {
App *app.App
+ Log *mlog.Logger
Session model.Session
Params *Params
Err *model.AppError
@@ -55,8 +55,12 @@ func (c *Context) LogError(err *model.AppError) {
err.Id == "web.check_browser_compatibility.app_error" {
c.LogDebug(err)
} else {
- mlog.Error(fmt.Sprintf("%v:%v code=%v rid=%v uid=%v ip=%v %v [details: %v]", c.Path, err.Where, err.StatusCode,
- c.RequestId, c.Session.UserId, c.IpAddress, err.SystemMessage(utils.TDefault), err.DetailedError), mlog.String("user_id", c.Session.UserId))
+ c.Log.Error(
+ err.SystemMessage(utils.TDefault),
+ mlog.String("err_where", err.Where),
+ mlog.Int("http_code", err.StatusCode),
+ mlog.String("err_details", err.DetailedError),
+ )
}
}
@@ -65,14 +69,22 @@ func (c *Context) LogInfo(err *model.AppError) {
if err.StatusCode == http.StatusUnauthorized {
c.LogDebug(err)
} else {
- mlog.Info(fmt.Sprintf("%v:%v code=%v rid=%v uid=%v ip=%v %v [details: %v]", c.Path, err.Where, err.StatusCode,
- c.RequestId, c.Session.UserId, c.IpAddress, err.SystemMessage(utils.TDefault), err.DetailedError), mlog.String("user_id", c.Session.UserId))
+ c.Log.Info(
+ err.SystemMessage(utils.TDefault),
+ mlog.String("err_where", err.Where),
+ mlog.Int("http_code", err.StatusCode),
+ mlog.String("err_details", err.DetailedError),
+ )
}
}
func (c *Context) LogDebug(err *model.AppError) {
- mlog.Debug(fmt.Sprintf("%v:%v code=%v rid=%v uid=%v ip=%v %v [details: %v]", c.Path, err.Where, err.StatusCode,
- c.RequestId, c.Session.UserId, c.IpAddress, err.SystemMessage(utils.TDefault), err.DetailedError), mlog.String("user_id", c.Session.UserId))
+ c.Log.Debug(
+ err.SystemMessage(utils.TDefault),
+ mlog.String("err_where", err.Where),
+ mlog.Int("http_code", err.StatusCode),
+ mlog.String("err_details", err.DetailedError),
+ )
}
func (c *Context) IsSystemAdmin() bool {