From d1227b5fc9de9f7a04fbf71292dd224aa8806411 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 21 Feb 2018 00:20:25 +0100 Subject: Use prefixed-formatter for better logging --- bridge/api/api.go | 2 +- bridge/bridge.go | 8 +++++++- bridge/discord/discord.go | 4 ++-- bridge/gitter/gitter.go | 2 +- bridge/irc/irc.go | 4 ++-- bridge/matrix/matrix.go | 2 +- bridge/mattermost/mattermost.go | 2 +- bridge/rocketchat/rocketchat.go | 2 +- bridge/slack/slack.go | 2 +- bridge/sshchat/sshchat.go | 2 +- bridge/steam/steam.go | 2 +- bridge/telegram/telegram.go | 2 +- bridge/xmpp/xmpp.go | 2 +- 13 files changed, 21 insertions(+), 15 deletions(-) (limited to 'bridge') diff --git a/bridge/api/api.go b/bridge/api/api.go index 6055cd5c..cbea9eee 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -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 { diff --git a/bridge/bridge.go b/bridge/bridge.go index 0a2bfed1..87db37e3 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -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 diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 70e11e0e..4ca68149 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -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 { diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go index 9f988f54..f11af6a7 100644 --- a/bridge/gitter/gitter.go +++ b/bridge/gitter/gitter.go @@ -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 { diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index d7b45b7f..958eb6c1 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -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 { diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index d0b435e6..56616357 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -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 { diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 2b93b9bf..bd1292bb 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -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 { diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go index 893cea74..dec02e5d 100644 --- a/bridge/rocketchat/rocketchat.go +++ b/bridge/rocketchat/rocketchat.go @@ -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 { diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index fa49da90..80886446 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -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 { diff --git a/bridge/sshchat/sshchat.go b/bridge/sshchat/sshchat.go index 4b91df01..cce4da59 100644 --- a/bridge/sshchat/sshchat.go +++ b/bridge/sshchat/sshchat.go @@ -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 { diff --git a/bridge/steam/steam.go b/bridge/steam/steam.go index 2ce6e0bc..b630c428 100644 --- a/bridge/steam/steam.go +++ b/bridge/steam/steam.go @@ -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 { diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 63853578..e411690c 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -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 { diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index c2f63e7a..45daee17 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -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 { -- cgit v1.2.3