diff --git a/bot/priority.go b/bot/priority.go index 6ade64a..18c831d 100644 --- a/bot/priority.go +++ b/bot/priority.go @@ -3,7 +3,8 @@ package bot import ( "fmt" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" + logstd "github.com/bdlm/std/logger" "dev.sum7.eu/genofire/logmania/database" ) @@ -21,7 +22,7 @@ func NewPriority(db *database.DB) *Command { return "invalid: [channel] Priority" } to := from - var max log.Level + var max logstd.Level var err error if len(params) > 1 { @@ -40,7 +41,7 @@ func NewPriority(db *database.DB) *Command { n.MaxPrioIn = max - return fmt.Sprintf("set filter for %s to %s", to, max.String()) + return fmt.Sprintf("set filter for %s to %s", to, max) }, }, { @@ -49,7 +50,7 @@ func NewPriority(db *database.DB) *Command { Action: func(from string, params []string) string { msg := "priority: \n" for _, n := range db.Notifies { - msg = fmt.Sprintf("%s%s - %s\n", msg, n.Address(), n.MaxPrioIn.String()) + msg = fmt.Sprintf("%s%s - %s\n", msg, n.Address(), n.MaxPrioIn) } return msg }, @@ -64,7 +65,7 @@ func NewPriority(db *database.DB) *Command { of := params[0] msg := "priority: \n" if notify, ok := db.NotifiesByAddress[of]; ok { - msg = fmt.Sprintf("%s %s is %s", msg, of, notify.MaxPrioIn.String()) + msg = fmt.Sprintf("%s %s is %s", msg, of, notify.MaxPrioIn) } return msg }, @@ -73,7 +74,7 @@ func NewPriority(db *database.DB) *Command { Action: func(from string, params []string) string { msg := "priority: \n" if notify, ok := db.NotifiesByAddress[from]; ok { - msg = fmt.Sprintf("%s %s is %s", msg, from, notify.MaxPrioIn.String()) + msg = fmt.Sprintf("%s %s is %s", msg, from, notify.MaxPrioIn) } return msg }, diff --git a/cmd/root.go b/cmd/root.go index 81b7740..6c642cc 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,7 +1,7 @@ package cmd import ( - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" "github.com/spf13/cobra" ) diff --git a/cmd/server.go b/cmd/server.go index d7d6d08..c772fb7 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -6,7 +6,7 @@ import ( "syscall" "time" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" "github.com/spf13/cobra" "dev.sum7.eu/genofire/golang-lib/file" diff --git a/database/main.go b/database/main.go index 3bc5507..e974b11 100644 --- a/database/main.go +++ b/database/main.go @@ -4,7 +4,8 @@ import ( "regexp" "time" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" + logstd "github.com/bdlm/std/logger" ) const AlertMsg = "alert service from logmania, device did not send new message for a while" @@ -13,7 +14,7 @@ type DB struct { // depraced Format -> transformation to new format by db.update() Hostname map[string]string `json:"hostname,omitempty"` HostTo map[string]map[string]bool `json:"host_to,omitempty"` - MaxPrioIn map[string]log.Level `json:"maxLevel,omitempty"` + MaxPrioIn map[string]logstd.Level `json:"maxLevel,omitempty"` RegexIn map[string]map[string]*regexp.Regexp `json:"regexIn,omitempty"` Lastseen map[string]time.Time `json:"lastseen,omitempty"` LastseenNotify map[string]time.Time `json:"-"` diff --git a/database/notify.go b/database/notify.go index 4e772d2..3963d30 100644 --- a/database/notify.go +++ b/database/notify.go @@ -4,7 +4,8 @@ import ( "regexp" "strings" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" + logstd "github.com/bdlm/std/logger" ) type Notify struct { @@ -12,7 +13,7 @@ type Notify struct { To string `json:"to"` RegexIn map[string]*regexp.Regexp `json:"regexIn"` RegexReplace map[string]string `json:"regexReplace"` - MaxPrioIn log.Level `json:"maxLevel"` + MaxPrioIn logstd.Level `json:"maxLevel"` regexReplaceExpression map[string]*regexp.Regexp } diff --git a/database/read.go b/database/read.go index 6629b78..902ccf9 100644 --- a/database/read.go +++ b/database/read.go @@ -2,7 +2,7 @@ package database import ( "dev.sum7.eu/genofire/golang-lib/file" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" ) func ReadDBFile(path string) *DB { diff --git a/input/all/internal.go b/input/all/internal.go index 552e3ce..943c1ab 100644 --- a/input/all/internal.go +++ b/input/all/internal.go @@ -1,7 +1,7 @@ package all import ( - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" "dev.sum7.eu/genofire/logmania/input" ) diff --git a/input/journald_json/internal.go b/input/journald_json/internal.go index c471bfa..dcde9a1 100644 --- a/input/journald_json/internal.go +++ b/input/journald_json/internal.go @@ -4,7 +4,8 @@ import ( "encoding/json" "strconv" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" + logstd "github.com/bdlm/std/logger" ) type JournalMessage struct { @@ -34,7 +35,7 @@ type JournalMessage struct { Message string `json:"MESSAGE"` } -var PriorityMap = map[int]log.Level{ +var PriorityMap = map[int]logstd.Level{ 0: log.PanicLevel, // emerg 1: log.PanicLevel, // alert 2: log.PanicLevel, // crit diff --git a/input/journald_json/main.go b/input/journald_json/main.go index 1df8481..78067b0 100644 --- a/input/journald_json/main.go +++ b/input/journald_json/main.go @@ -3,8 +3,8 @@ package journald_json import ( "net" + "github.com/bdlm/log" "github.com/mitchellh/mapstructure" - log "github.com/sirupsen/logrus" "dev.sum7.eu/genofire/logmania/input" ) diff --git a/input/main.go b/input/main.go index 363af54..541deda 100644 --- a/input/main.go +++ b/input/main.go @@ -1,7 +1,7 @@ package input import ( - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" ) var Register = make(map[string]Init) diff --git a/input/syslog/internal.go b/input/syslog/internal.go index 5acde82..65ac315 100644 --- a/input/syslog/internal.go +++ b/input/syslog/internal.go @@ -1,12 +1,13 @@ package syslog import ( - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" + logstd "github.com/bdlm/std/logger" libSyslog "dev.sum7.eu/genofire/logmania/lib/syslog" ) -var SyslogPriorityMap = map[int]log.Level{ +var SyslogPriorityMap = map[int]logstd.Level{ 0: log.PanicLevel, 1: log.PanicLevel, 2: log.PanicLevel, diff --git a/input/syslog/internal_test.go b/input/syslog/internal_test.go index ff52ebf..dff968b 100644 --- a/input/syslog/internal_test.go +++ b/input/syslog/internal_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" ) func TestToEntry(t *testing.T) { diff --git a/input/syslog/main.go b/input/syslog/main.go index 8805a7f..5fbb952 100644 --- a/input/syslog/main.go +++ b/input/syslog/main.go @@ -3,8 +3,8 @@ package syslog import ( "net" + "github.com/bdlm/log" "github.com/mitchellh/mapstructure" - log "github.com/sirupsen/logrus" "dev.sum7.eu/genofire/logmania/input" ) diff --git a/output/all/internal.go b/output/all/internal.go index ced1d69..b02ef12 100644 --- a/output/all/internal.go +++ b/output/all/internal.go @@ -1,7 +1,7 @@ package all import ( - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" "dev.sum7.eu/genofire/logmania/bot" "dev.sum7.eu/genofire/logmania/database" @@ -62,7 +62,7 @@ func (out *Output) sender() { } } if !send { - logger.Warnf("notify not send to %s: [%s] %s", to.Address(), c.Level.String(), c.Message) + logger.Warnf("notify not send to %s: [%s] %s", to.Address(), c.Level, c.Message) } } } diff --git a/output/file/main.go b/output/file/main.go index 48d3d10..d0f49c6 100644 --- a/output/file/main.go +++ b/output/file/main.go @@ -5,8 +5,8 @@ import ( "path" "regexp" + "github.com/bdlm/log" "github.com/mitchellh/mapstructure" - log "github.com/sirupsen/logrus" "dev.sum7.eu/genofire/logmania/bot" "dev.sum7.eu/genofire/logmania/database" diff --git a/output/main.go b/output/main.go index 77b528d..02dbea2 100644 --- a/output/main.go +++ b/output/main.go @@ -1,7 +1,7 @@ package output import ( - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" "dev.sum7.eu/genofire/logmania/bot" "dev.sum7.eu/genofire/logmania/database" diff --git a/output/xmpp/main.go b/output/xmpp/main.go index 4282b7a..38fd163 100644 --- a/output/xmpp/main.go +++ b/output/xmpp/main.go @@ -8,8 +8,8 @@ import ( xmpp "dev.sum7.eu/genofire/yaja/xmpp" "dev.sum7.eu/genofire/yaja/xmpp/base" "dev.sum7.eu/genofire/yaja/xmpp/x/muc" + "github.com/bdlm/log" "github.com/mitchellh/mapstructure" - log "github.com/sirupsen/logrus" "dev.sum7.eu/genofire/logmania/bot" "dev.sum7.eu/genofire/logmania/database" @@ -49,11 +49,7 @@ func Init(configInterface interface{}, db *database.DB, bot *bot.Bot) output.Out channels := make(map[string]bool) jid := xmppbase.NewJID(config.JID) - client := &xmpp_client.Client{ - JID: jid, - Logging: logger.WithField("jid", jid.String()), - } - err := client.Connect(config.Password) + client, err := xmpp_client.NewClient(jid, config.Password) if err != nil { logger.Error(err)