refactor: replace logrus with log/slog
This commit is contained in:
26
utils/logger.go
Normal file
26
utils/logger.go
Normal 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...))
|
||||
}
|
Reference in New Issue
Block a user