-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.go
74 lines (70 loc) · 2.09 KB
/
logger.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package ngrpc
import (
"context"
"log"
)
// Logger logger
type Logger interface {
Debugf(ctx context.Context, format string, args ...interface{})
Debugln(ctx context.Context, args ...interface{})
Infof(ctx context.Context, format string, args ...interface{})
Infoln(ctx context.Context, args ...interface{})
Warnf(ctx context.Context, format string, args ...interface{})
Warnln(ctx context.Context, args ...interface{})
Errorf(ctx context.Context, format string, args ...interface{})
Errorln(ctx context.Context, args ...interface{})
Fatalf(ctx context.Context, format string, args ...interface{})
Fatalln(ctx context.Context, args ...interface{})
}
type StdLogger struct {
}
func (StdLogger) Debugf(ctx context.Context, format string, args ...interface{}) {
log.Printf("[Debug] "+format, args...)
}
func (StdLogger) Debugln(ctx context.Context, args ...interface{}) {
nArgs := []interface{}{
"[Debug]",
}
nArgs = append(nArgs, args...)
log.Println(nArgs...)
}
func (StdLogger) Infof(ctx context.Context, format string, args ...interface{}) {
log.Printf("[INFO] "+format, args...)
}
func (StdLogger) Infoln(ctx context.Context, args ...interface{}) {
nArgs := []interface{}{
"[INFO]",
}
nArgs = append(nArgs, args...)
log.Println(nArgs...)
}
func (StdLogger) Warnf(ctx context.Context, format string, args ...interface{}) {
log.Printf("[Warn] "+format, args...)
}
func (StdLogger) Warnln(ctx context.Context, args ...interface{}) {
nArgs := []interface{}{
"[Warn]",
}
nArgs = append(nArgs, args...)
log.Println(nArgs...)
}
func (StdLogger) Errorf(ctx context.Context, format string, args ...interface{}) {
log.Printf("[Error] "+format, args...)
}
func (StdLogger) Errorln(ctx context.Context, args ...interface{}) {
nArgs := []interface{}{
"[Error]",
}
nArgs = append(nArgs, args...)
log.Println(nArgs...)
}
func (StdLogger) Fatalf(ctx context.Context, format string, args ...interface{}) {
log.Fatalf("[Fatal] "+format, args...)
}
func (StdLogger) Fatalln(ctx context.Context, args ...interface{}) {
nArgs := []interface{}{
"[Fatal]",
}
nArgs = append(nArgs, args...)
log.Fatalln(nArgs...)
}