forked from scottjbarr/redis
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogger.go
More file actions
42 lines (35 loc) · 1.07 KB
/
Copy pathlogger.go
File metadata and controls
42 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package redis
import (
"context"
"fmt"
"log"
"os"
)
// Logger is a minimal interface for a logger
type Logger interface {
Info(context.Context, string, ...interface{})
Warn(context.Context, string, ...interface{})
Error(context.Context, string, ...interface{})
}
// LogWrapper wraps a standard Logger to implement the Logger interface.
type LogWrapper struct {
Logger *log.Logger
}
// NewLogWrapper returns a new LogWrapper.
func NewLogWrapper() *LogWrapper {
return &LogWrapper{
Logger: log.New(os.Stdout, "", log.Flags()),
}
}
// Info implements the Logger interface.
func (l *LogWrapper) Info(ctx context.Context, format string, args ...interface{}) {
log.Printf(fmt.Sprintf("INFO %s", format), args...)
}
// Warn implements the Logger interface.
func (l *LogWrapper) Warn(ctx context.Context, format string, args ...interface{}) {
log.Printf(fmt.Sprintf("WARN %s", format), args...)
}
// Error implements the Logger interface.
func (l *LogWrapper) Error(ctx context.Context, format string, args ...interface{}) {
log.Printf(fmt.Sprintf("ERROR %s", format), args...)
}