mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 16:20:02 +00:00
Knut Ahlers
c63793be2d
and fix some newly appearing linter errors Signed-off-by: Knut Ahlers <knut@ahlers.me>
30 lines
844 B
Go
30 lines
844 B
Go
package database
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type (
|
|
// LogWriter implements a logger for the gorm logging
|
|
LogWriter struct{ io.Writer }
|
|
)
|
|
|
|
// NewLogrusLogWriterWithLevel creates a new LogWriter with the given
|
|
// logrus.Logger and the specified logrus.Level
|
|
func NewLogrusLogWriterWithLevel(logger *logrus.Logger, level logrus.Level, dbDriver string) LogWriter {
|
|
writer := logger.WithField("database", dbDriver).WriterLevel(level)
|
|
return LogWriter{writer}
|
|
}
|
|
|
|
// Print implements the gorm.Logger interface
|
|
func (l LogWriter) Print(a ...any) {
|
|
fmt.Fprint(l.Writer, a...) //nolint:errcheck // Interface ignores this error
|
|
}
|
|
|
|
// Printf implements the gorm.Logger interface
|
|
func (l LogWriter) Printf(format string, a ...any) {
|
|
fmt.Fprintf(l.Writer, format, a...) //nolint:errcheck // Interface ignores this error
|
|
}
|