change logging lib
This commit is contained in:
parent
a5b0b06b3b
commit
840142fc1d
|
@ -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
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/bdlm/log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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:"-"`
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package all
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/bdlm/log"
|
||||
|
||||
"dev.sum7.eu/genofire/logmania/input"
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package input
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/bdlm/log"
|
||||
)
|
||||
|
||||
var Register = make(map[string]Init)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/bdlm/log"
|
||||
)
|
||||
|
||||
func TestToEntry(t *testing.T) {
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue