-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstd.go
56 lines (44 loc) · 1.31 KB
/
std.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package logger
import (
"context"
"log"
)
type stdErrLogger struct{}
// Debug logs a debug message.
func (l *stdErrLogger) Debug(_ context.Context, v interface{}) {
std("DEBUG", v)
}
// Debugf logs a debug message with format.
func (l *stdErrLogger) Debugf(_ context.Context, format string, v ...interface{}) {
stdf("DEBUG", format, v...)
}
// Info logs a info message.
func (l *stdErrLogger) Info(_ context.Context, v interface{}) {
std("INFO ", v)
}
// Infof logs a info message with format.
func (l *stdErrLogger) Infof(_ context.Context, format string, v ...interface{}) {
stdf("INFO ", format, v...)
}
// Warn logs a warning message.
func (l *stdErrLogger) Warn(_ context.Context, v interface{}) {
std("WARN ", v)
}
// Warnf logs a warning message with format.
func (l *stdErrLogger) Warnf(_ context.Context, format string, v ...interface{}) {
stdf("WARN ", format, v...)
}
// Error logs an error message.
func (l *stdErrLogger) Error(_ context.Context, v interface{}) {
std("ERROR", v)
}
// Errorf logs an error message with format.
func (l *stdErrLogger) Errorf(_ context.Context, format string, v ...interface{}) {
stdf("ERROR", format, v...)
}
func std(level string, v ...interface{}) {
log.Printf(level+": %s", v...)
}
func stdf(level, format string, v ...interface{}) {
log.Printf(level+": "+format, v...)
}