4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 18:59:24 +00:00

Use prefixed-formatter for better logging

This commit is contained in:
Wim
2018-02-21 00:20:25 +01:00
parent 6ea368c383
commit d1227b5fc9
17 changed files with 71 additions and 42 deletions

View File

@ -30,7 +30,7 @@ var flog *log.Entry
var protocol = "api"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Api {

View File

@ -36,6 +36,12 @@ type Bridge struct {
Joined map[string]bool
}
var flog *log.Entry
func init() {
flog = log.WithFields(log.Fields{"prefix": "bridge"})
}
func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) *Bridge {
b := new(Bridge)
b.Channels = make(map[string]config.ChannelInfo)
@ -100,7 +106,7 @@ func (b *Bridge) JoinChannels() error {
func (b *Bridge) joinChannels(channels map[string]config.ChannelInfo, exists map[string]bool) error {
for ID, channel := range channels {
if !exists[ID] {
log.Infof("%s: joining %s (ID: %s)", b.Account, channel.Name, ID)
flog.Infof("%s: joining %s (ID: %s)", b.Account, channel.Name, ID)
err := b.JoinChannel(channel)
if err != nil {
return err

View File

@ -4,8 +4,8 @@ import (
"bytes"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
log "github.com/sirupsen/logrus"
"github.com/bwmarrin/discordgo"
log "github.com/sirupsen/logrus"
"regexp"
"strings"
"sync"
@ -29,7 +29,7 @@ var flog *log.Entry
var protocol = "discord"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *bdiscord {

View File

@ -21,7 +21,7 @@ var flog *log.Entry
var protocol = "gitter"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bgitter {

View File

@ -6,11 +6,11 @@ import (
"fmt"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
log "github.com/sirupsen/logrus"
"github.com/lrstanley/girc"
"github.com/paulrosania/go-charset/charset"
_ "github.com/paulrosania/go-charset/data"
"github.com/saintfish/chardet"
log "github.com/sirupsen/logrus"
"io"
"io/ioutil"
"net"
@ -37,7 +37,7 @@ var flog *log.Entry
var protocol = "irc"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Birc {

View File

@ -25,7 +25,7 @@ var flog *log.Entry
var protocol = "matrix"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bmatrix {

View File

@ -42,7 +42,7 @@ var flog *log.Entry
var protocol = "mattermost"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bmattermost {

View File

@ -22,7 +22,7 @@ var flog *log.Entry
var protocol = "rocketchat"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Brocketchat {

View File

@ -40,7 +40,7 @@ var flog *log.Entry
var protocol = "slack"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bslack {

View File

@ -20,7 +20,7 @@ var flog *log.Entry
var protocol = "sshchat"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bsshchat {

View File

@ -25,7 +25,7 @@ var flog *log.Entry
var protocol = "steam"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bsteam {

View File

@ -21,7 +21,7 @@ var flog *log.Entry
var protocol = "telegram"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Btelegram {

View File

@ -22,7 +22,7 @@ var flog *log.Entry
var protocol = "xmpp"
func init() {
flog = log.WithFields(log.Fields{"module": protocol})
flog = log.WithFields(log.Fields{"prefix": protocol})
}
func New(cfg *config.BridgeConfig) *Bxmpp {