Replace logrus with slog

This commit is contained in:
eleksir
2025-11-15 16:15:00 +03:00
parent ee5d40cfee
commit a128b473ff
388 changed files with 272 additions and 224310 deletions

View File

@@ -3,13 +3,13 @@ package jabber
import (
"bufio"
"buny-jabber-bot/internal/log"
"fmt"
"io"
"os"
"strings"
"github.com/jbrukh/bayesian"
log "github.com/sirupsen/logrus"
)
const (

View File

@@ -1,6 +1,7 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"encoding/json"
"errors"
"fmt"
@@ -8,7 +9,6 @@ import (
"path/filepath"
"github.com/hjson/hjson-go"
log "github.com/sirupsen/logrus"
)
// ReadWhitelist читает и валидирует белые списки пользователей.

View File

@@ -1,6 +1,7 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"encoding/json"
"fmt"
"regexp"
@@ -9,7 +10,6 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/eleksir/go-xmpp"
log "github.com/sirupsen/logrus"
)
// BunyPresense производит проверку по бело-чёрным спискам. Если presence пришёл от злодея (из чёрного списка), то

View File

@@ -1,13 +1,13 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"fmt"
"slices"
"strings"
"github.com/davecgh/go-spew/spew"
"github.com/eleksir/go-xmpp"
log "github.com/sirupsen/logrus"
)
// Cmd парсит команды из чятика.

View File

@@ -1,6 +1,7 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"encoding/json"
"encoding/xml"
"fmt"
@@ -12,7 +13,6 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/eleksir/go-xmpp"
log "github.com/sirupsen/logrus"
)
// ParseEvent парсит ивенты, прилетающие из модуля xmpp (изменения presence, фразы участников, ошибки).

View File

@@ -1,9 +1,8 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"time"
log "github.com/sirupsen/logrus"
)
// MyLoop - основной цикл программы.
@@ -25,7 +24,7 @@ func (j *Jabber) MyLoop() error {
// Установим коннект.
if err := j.EstablishConnection(); err != nil {
log.Error(err)
log.Error(err.Error())
return err
}
@@ -36,7 +35,7 @@ func (j *Jabber) MyLoop() error {
j.GTomb.Go(
func() error {
err := j.ProbeServerLiveness()
log.Error(err)
log.Error(err.Error())
return err
},

View File

@@ -1,11 +1,11 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"fmt"
"github.com/eleksir/go-xmpp"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
// QuerySoftwareVersion запрошивает версию и название клиента.

View File

@@ -1,6 +1,7 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"encoding/json"
"errors"
"fmt"
@@ -8,7 +9,6 @@ import (
"path/filepath"
"github.com/hjson/hjson-go"
log "github.com/sirupsen/logrus"
)
// ReadConfig читает и валидирует конфиг, а также выставляет некоторые default-ы, если значений для параметров в конфиге

View File

@@ -1,11 +1,11 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"os"
"syscall"
"github.com/eleksir/go-xmpp"
log "github.com/sirupsen/logrus"
)
// SigHandler срабатывает если происходит завершение программы, инициированное либо init-ом, либо пользователем.
@@ -16,11 +16,11 @@ func (j *Jabber) SigHandler() error {
for s := range j.SigChan {
switch s {
case syscall.SIGINT:
log.Infoln("Got SIGINT, quitting")
log.Info("Got SIGINT, quitting")
case syscall.SIGTERM:
log.Infoln("Got SIGTERM, quitting")
log.Info("Got SIGTERM, quitting")
case syscall.SIGQUIT:
log.Infoln("Got SIGQUIT, quitting")
log.Info("Got SIGQUIT, quitting")
// Заходим на новую итерацию, если у нас "неинтересный" сигнал.
default:
@@ -48,7 +48,7 @@ func (j *Jabber) SigHandler() error {
}
// И закрываем соединение.
log.Infoln("Closing connection to jabber server")
log.Info("Closing connection to jabber server")
if err := j.Talk.Close(); err != nil {
log.Infof("Unable to close connection to jabber server: %s", err)

View File

@@ -1,6 +1,7 @@
package jabber
import (
"buny-jabber-bot/internal/log"
"encoding/json"
"fmt"
"math/rand"
@@ -10,7 +11,6 @@ import (
"time"
"github.com/eleksir/go-xmpp"
log "github.com/sirupsen/logrus"
)
// RandomPhrase выдаёт одну рандомную фразу из даденного списка фраз.