diff options
author | Wim <wim@42.be> | 2018-02-21 01:11:41 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-21 01:11:41 +0100 |
commit | 67d2398fa8358fd3bad7ede01620294abd2b4eb7 (patch) | |
tree | 55f66a72c6d36833c83e5645d1e764c70f24d9a9 /matterclient | |
parent | 5f3b6ec007c8f3ff9e6d1f0d89f45819fbefd1cf (diff) | |
download | matterbridge-msglm-67d2398fa8358fd3bad7ede01620294abd2b4eb7.tar.gz matterbridge-msglm-67d2398fa8358fd3bad7ede01620294abd2b4eb7.tar.bz2 matterbridge-msglm-67d2398fa8358fd3bad7ede01620294abd2b4eb7.zip |
Make matterclient work with prefixed log
Diffstat (limited to 'matterclient')
-rw-r--r-- | matterclient/matterclient.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index 9e44705d..27e96163 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -14,6 +14,7 @@ import ( "time" log "github.com/sirupsen/logrus" + prefixed "github.com/x-cray/logrus-prefixed-formatter" "github.com/gorilla/websocket" "github.com/hashicorp/golang-lru" @@ -73,12 +74,16 @@ 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)} - mmclient.log = log.WithFields(log.Fields{"module": "matterclient"}) - log.SetFormatter(&log.TextFormatter{FullTimestamp: true}) + log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true}) + mmclient.log = log.WithFields(log.Fields{"prefix": "matterclient"}) mmclient.lruCache, _ = lru.New(500) return mmclient } +func (m *MMClient) SetDebugLog() { + log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true, FullTimestamp: false}) +} + func (m *MMClient) SetLogLevel(level string) { l, err := log.ParseLevel(level) if err != nil { |