2022-10-22 22:08:02 +00:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
logWriter struct{ io.Writer }
|
|
|
|
)
|
|
|
|
|
2022-10-29 13:01:01 +00:00
|
|
|
func newLogrusLogWriterWithLevel(level logrus.Level, dbDriver string) logWriter {
|
|
|
|
writer := logrus.WithField("database", dbDriver).WriterLevel(level)
|
2022-10-22 22:08:02 +00:00
|
|
|
return logWriter{writer}
|
|
|
|
}
|
|
|
|
|
2022-10-29 13:01:01 +00:00
|
|
|
func (l logWriter) Print(a ...any) {
|
|
|
|
fmt.Fprint(l.Writer, a...)
|
|
|
|
}
|
|
|
|
|
2022-10-22 22:08:02 +00:00
|
|
|
func (l logWriter) Printf(format string, a ...any) {
|
|
|
|
fmt.Fprintf(l.Writer, format, a...)
|
|
|
|
}
|