From da8e415ae1fb899df4fb05a8a81934e205fb4765 Mon Sep 17 00:00:00 2001 From: Duco van Amstel Date: Wed, 26 Dec 2018 15:16:09 +0100 Subject: Use logrus imports instead of log (#662) --- matterclient/channels.go | 4 ++-- matterclient/matterclient.go | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'matterclient') diff --git a/matterclient/channels.go b/matterclient/channels.go index 84d43bae..ddd4d006 100644 --- a/matterclient/channels.go +++ b/matterclient/channels.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/mattermost/mattermost-server/model" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" ) // GetChannels returns all channels we're members off @@ -192,7 +192,7 @@ func (m *MMClient) UpdateChannelHeader(channelId string, header string) { //noli m.log.Debugf("updating channelheader %#v, %#v", channelId, header) _, resp := m.Client.UpdateChannel(channel) if resp.Error != nil { - log.Error(resp.Error) + logrus.Error(resp.Error) } } diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index f15b1d1b..07994c61 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -12,7 +12,7 @@ import ( "github.com/jpillora/backoff" prefixed "github.com/matterbridge/logrus-prefixed-formatter" "github.com/mattermost/mattermost-server/model" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" ) type Credentials struct { @@ -55,7 +55,7 @@ type MMClient struct { User *model.User Users map[string]*model.User MessageChan chan *Message - log *log.Entry + log *logrus.Entry WsClient *websocket.Conn WsQuit bool WsAway bool @@ -70,23 +70,23 @@ type MMClient struct { func New(login, pass, team, server string) *MMClient { cred := &Credentials{Login: login, Pass: pass, Team: team, Server: server} mmclient := &MMClient{Credentials: cred, MessageChan: make(chan *Message, 100), Users: make(map[string]*model.User)} - log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true}) - mmclient.log = log.WithFields(log.Fields{"prefix": "matterclient"}) + logrus.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true}) + mmclient.log = logrus.WithFields(logrus.Fields{"prefix": "matterclient"}) mmclient.lruCache, _ = lru.New(500) return mmclient } func (m *MMClient) SetDebugLog() { - log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true, FullTimestamp: false, ForceFormatting: true}) + logrus.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true, FullTimestamp: false, ForceFormatting: true}) } func (m *MMClient) SetLogLevel(level string) { - l, err := log.ParseLevel(level) + l, err := logrus.ParseLevel(level) if err != nil { - log.SetLevel(log.InfoLevel) + logrus.SetLevel(logrus.InfoLevel) return } - log.SetLevel(l) + logrus.SetLevel(l) } func (m *MMClient) Login() error { @@ -209,7 +209,7 @@ func (m *MMClient) StatusLoop() { } if m.WsConnected { if err := m.checkAlive(); err != nil { - log.Errorf("Connection is not alive: %#v", err) + logrus.Errorf("Connection is not alive: %#v", err) } select { case <-m.WsPingChan: @@ -222,7 +222,7 @@ func (m *MMClient) StatusLoop() { m.WsQuit = false err := m.Login() if err != nil { - log.Errorf("Login failed: %#v", err) + logrus.Errorf("Login failed: %#v", err) break } if m.OnWsConnect != nil { -- cgit v1.2.3