redis/internal/log.go

27 lines
522 B
Go
Raw Normal View History

2016-04-09 14:52:01 +03:00
package internal
import (
"context"
"fmt"
2016-04-09 14:52:01 +03:00
"log"
2019-06-17 12:32:40 +03:00
"os"
2016-04-09 14:52:01 +03:00
)
2020-03-30 17:02:17 +03:00
type Logging interface {
Printf(ctx context.Context, format string, v ...interface{})
2020-03-30 17:02:17 +03:00
}
type logger struct {
log *log.Logger
}
func (l *logger) Printf(ctx context.Context, format string, v ...interface{}) {
_ = l.log.Output(2, fmt.Sprintf(format, v...))
}
// Logger calls Output to print to the stderr.
// Arguments are handled in the manner of fmt.Print.
var Logger Logging = &logger{
log: log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile),
}