mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-22 12:50:27 +00:00
Make matterclient work with prefixed log
This commit is contained in:
parent
5f3b6ec007
commit
67d2398fa8
@ -364,6 +364,9 @@ func (b *Bmattermost) apiLogin() error {
|
|||||||
|
|
||||||
b.mc = matterclient.New(b.Config.Login, password,
|
b.mc = matterclient.New(b.Config.Login, password,
|
||||||
b.Config.Team, b.Config.Server)
|
b.Config.Team, b.Config.Server)
|
||||||
|
if b.General.Debug {
|
||||||
|
b.mc.SetLogLevel("debug")
|
||||||
|
}
|
||||||
b.mc.SkipTLSVerify = b.Config.SkipTLSVerify
|
b.mc.SkipTLSVerify = b.Config.SkipTLSVerify
|
||||||
b.mc.NoTLS = b.Config.NoTLS
|
b.mc.NoTLS = b.Config.NoTLS
|
||||||
flog.Infof("Connecting %s (team: %s) on %s", b.Config.Login, b.Config.Team, b.Config.Server)
|
flog.Infof("Connecting %s (team: %s) on %s", b.Config.Login, b.Config.Team, b.Config.Server)
|
||||||
|
@ -18,7 +18,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 10, DisableColors: true, FullTimestamp: true})
|
log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true, FullTimestamp: true})
|
||||||
flog := log.WithFields(log.Fields{"prefix": "main"})
|
flog := log.WithFields(log.Fields{"prefix": "main"})
|
||||||
flagConfig := flag.String("conf", "matterbridge.toml", "config file")
|
flagConfig := flag.String("conf", "matterbridge.toml", "config file")
|
||||||
flagDebug := flag.Bool("debug", false, "enable debug")
|
flagDebug := flag.Bool("debug", false, "enable debug")
|
||||||
@ -34,7 +34,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if *flagDebug || os.Getenv("DEBUG") == "1" {
|
if *flagDebug || os.Getenv("DEBUG") == "1" {
|
||||||
log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 10, DisableColors: true, FullTimestamp: false})
|
log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true, FullTimestamp: false})
|
||||||
flog.Info("Enabling debug")
|
flog.Info("Enabling debug")
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/hashicorp/golang-lru"
|
"github.com/hashicorp/golang-lru"
|
||||||
@ -73,12 +74,16 @@ type MMClient struct {
|
|||||||
func New(login, pass, team, server string) *MMClient {
|
func New(login, pass, team, server string) *MMClient {
|
||||||
cred := &Credentials{Login: login, Pass: pass, Team: team, Server: server}
|
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 := &MMClient{Credentials: cred, MessageChan: make(chan *Message, 100), Users: make(map[string]*model.User)}
|
||||||
mmclient.log = log.WithFields(log.Fields{"module": "matterclient"})
|
log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true})
|
||||||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
mmclient.log = log.WithFields(log.Fields{"prefix": "matterclient"})
|
||||||
mmclient.lruCache, _ = lru.New(500)
|
mmclient.lruCache, _ = lru.New(500)
|
||||||
return mmclient
|
return mmclient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MMClient) SetDebugLog() {
|
||||||
|
log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 13, DisableColors: true, FullTimestamp: false})
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MMClient) SetLogLevel(level string) {
|
func (m *MMClient) SetLogLevel(level string) {
|
||||||
l, err := log.ParseLevel(level)
|
l, err := log.ParseLevel(level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user