2022-10-22 22:08:02 +00:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2023-11-25 19:23:34 +00:00
|
|
|
LogWriter struct{ io.Writer }
|
2022-10-22 22:08:02 +00:00
|
|
|
)
|
|
|
|
|
2023-11-25 19:23:34 +00:00
|
|
|
func NewLogrusLogWriterWithLevel(logger *logrus.Logger, level logrus.Level, dbDriver string) LogWriter {
|
|
|
|
writer := logger.WithField("database", dbDriver).WriterLevel(level)
|
|
|
|
return LogWriter{writer}
|
2022-10-22 22:08:02 +00:00
|
|
|
}
|
|
|
|
|
2023-11-25 19:23:34 +00:00
|
|
|
func (l LogWriter) Print(a ...any) {
|
2022-10-29 13:01:01 +00:00
|
|
|
fmt.Fprint(l.Writer, a...)
|
|
|
|
}
|
|
|
|
|
2023-11-25 19:23:34 +00:00
|
|
|
func (l LogWriter) Printf(format string, a ...any) {
|
2022-10-22 22:08:02 +00:00
|
|
|
fmt.Fprintf(l.Writer, format, a...)
|
|
|
|
}
|