refactor: replace logrus with log/slog

This commit is contained in:
rramiachraf
2024-05-02 21:29:50 +01:00
parent 56c745d6f5
commit c940b4a2cd
18 changed files with 120 additions and 70 deletions

26
utils/logger.go Normal file
View File

@ -0,0 +1,26 @@
package utils
import (
"fmt"
"io"
"log/slog"
)
type Logger struct {
slog *slog.Logger
}
func NewLogger(w io.WriteCloser) *Logger {
handler := slog.NewTextHandler(w, &slog.HandlerOptions{})
sl := slog.New(handler)
return &Logger{slog: sl}
}
func (l *Logger) Error(f string, args ...any) {
l.slog.Error(fmt.Sprintf(f, args...))
}
func (l *Logger) Info(f string, args ...any) {
l.slog.Info(fmt.Sprintf(f, args...))
}