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