diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-04-27 12:49:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 12:49:45 -0700 |
commit | 686c2fbab7607d42183ae685a27ea3d7dce8c3f6 (patch) | |
tree | 53ed73cada57bc43f342ac10e2f842cddb095218 /app/web_hub.go | |
parent | 2acbc77d78456d7ba76ceb687b18985d7d92f814 (diff) | |
download | chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.gz chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.bz2 chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.zip |
Structured logging (#8673)
* Implementing structured logging
* Changes to en.json to allow refactor to run.
* Fixing global logger
* Structured logger initalization.
* Add caller.
* Do some log redirection.
* Auto refactor
* Cleaning up l4g reference and removing dependancy.
* Removing junk.
* Copyright headers.
* Fixing tests
* Revert "Changes to en.json to allow refactor to run."
This reverts commit fd8249e99bcad0231e6ea65cd77c32aae9a54026.
* Fixing some auto refactor strangeness and typo.
* Making keys more human readable.
Diffstat (limited to 'app/web_hub.go')
-rw-r--r-- | app/web_hub.go | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/app/web_hub.go b/app/web_hub.go index 971b03481..18eb97c8e 100644 --- a/app/web_hub.go +++ b/app/web_hub.go @@ -13,10 +13,8 @@ import ( "sync/atomic" "time" - l4g "github.com/alecthomas/log4go" - + "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) const ( @@ -66,7 +64,7 @@ func (a *App) TotalWebsocketConnections() int { func (a *App) HubStart() { // Total number of hubs is twice the number of CPUs. numberOfHubs := runtime.NumCPU() * 2 - l4g.Info(utils.T("api.web_hub.start.starting.debug"), numberOfHubs) + mlog.Info(fmt.Sprintf("Starting %v websocket hubs", numberOfHubs)) a.Hubs = make([]*Hub, numberOfHubs) a.HubsStopCheckingForDeadlock = make(chan bool, 1) @@ -89,7 +87,7 @@ func (a *App) HubStart() { case <-ticker.C: for _, hub := range a.Hubs { if len(hub.broadcast) >= DEADLOCK_WARN { - l4g.Error("Hub processing might be deadlock on hub %v goroutine %v with %v events in the buffer", hub.connectionIndex, hub.goroutineId, len(hub.broadcast)) + mlog.Error(fmt.Sprintf("Hub processing might be deadlock on hub %v goroutine %v with %v events in the buffer", hub.connectionIndex, hub.goroutineId, len(hub.broadcast))) buf := make([]byte, 1<<16) runtime.Stack(buf, true) output := fmt.Sprintf("%s", buf) @@ -97,7 +95,7 @@ func (a *App) HubStart() { for _, part := range splits { if strings.Contains(part, fmt.Sprintf("%v", hub.goroutineId)) { - l4g.Error("Trace for possible deadlock goroutine %v", part) + mlog.Error(fmt.Sprintf("Trace for possible deadlock goroutine %v", part)) } } } @@ -111,12 +109,12 @@ func (a *App) HubStart() { } func (a *App) HubStop() { - l4g.Info(utils.T("api.web_hub.start.stopping.debug")) + mlog.Info("stopping websocket hub connections") select { case a.HubsStopCheckingForDeadlock <- true: default: - l4g.Warn("We appear to have already sent the stop checking for deadlocks command") + mlog.Warn("We appear to have already sent the stop checking for deadlocks command") } for _, hub := range a.Hubs { @@ -367,7 +365,7 @@ func (h *Hub) Start() { doStart = func() { h.goroutineId = getGoroutineId() - l4g.Debug("Hub for index %v is starting with goroutine %v", h.connectionIndex, h.goroutineId) + mlog.Debug(fmt.Sprintf("Hub for index %v is starting with goroutine %v", h.connectionIndex, h.goroutineId)) connections := newHubConnectionIndex() @@ -404,7 +402,7 @@ func (h *Hub) Start() { select { case webCon.Send <- msg: default: - l4g.Error(fmt.Sprintf("webhub.broadcast: cannot send, closing websocket for userId=%v", webCon.UserId)) + mlog.Error(fmt.Sprintf("webhub.broadcast: cannot send, closing websocket for userId=%v", webCon.UserId)) close(webCon.Send) connections.Remove(webCon) } @@ -438,12 +436,12 @@ func (h *Hub) Start() { doRecover = func() { if !h.ExplicitStop { if r := recover(); r != nil { - l4g.Error(fmt.Sprintf("Recovering from Hub panic. Panic was: %v", r)) + mlog.Error(fmt.Sprintf("Recovering from Hub panic. Panic was: %v", r)) } else { - l4g.Error("Webhub stopped unexpectedly. Recovering.") + mlog.Error("Webhub stopped unexpectedly. Recovering.") } - l4g.Error(string(debug.Stack())) + mlog.Error(string(debug.Stack())) go doRecoverableStart() } |