log.go 522 B

1234567891011121314151617181920212223242526
  1. package internal
  2. import (
  3. "context"
  4. "fmt"
  5. "log"
  6. "os"
  7. )
  8. type Logging interface {
  9. Printf(ctx context.Context, format string, v ...interface{})
  10. }
  11. type logger struct {
  12. log *log.Logger
  13. }
  14. func (l *logger) Printf(ctx context.Context, format string, v ...interface{}) {
  15. _ = l.log.Output(2, fmt.Sprintf(format, v...))
  16. }
  17. // Logger calls Output to print to the stderr.
  18. // Arguments are handled in the manner of fmt.Print.
  19. var Logger Logging = &logger{
  20. log: log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile),
  21. }