twitch-bot/pkg/database/logger.go
Knut Ahlers 231704f8b3
[core] Configure logger for mysql driver
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2022-10-29 15:01:01 +02:00

25 lines
455 B
Go

package database
import (
"fmt"
"io"
"github.com/sirupsen/logrus"
)
type (
logWriter struct{ io.Writer }
)
func newLogrusLogWriterWithLevel(level logrus.Level, dbDriver string) logWriter {
writer := logrus.WithField("database", dbDriver).WriterLevel(level)
return logWriter{writer}
}
func (l logWriter) Print(a ...any) {
fmt.Fprint(l.Writer, a...)
}
func (l logWriter) Printf(format string, a ...any) {
fmt.Fprintf(l.Writer, format, a...)
}