-
Notifications
You must be signed in to change notification settings - Fork 153
/
api.go
67 lines (51 loc) · 1.35 KB
/
api.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
package logger
import (
"fmt"
"github.com/go-logr/logr"
"github.com/go-logr/zapr"
"go.uber.org/zap"
)
type ApiLogger struct {
logger logr.Logger
}
func NewApiLogger() Logger {
zap, err := zap.NewProduction()
if err != nil {
panic(err)
}
logger := zapr.NewLogger(zap)
return ApiLogger{
logger: logger,
}
}
func (l ApiLogger) Println(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Printf(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Infow(msg string, kv ...interface{}) {
l.logger.Info(msg, kv...)
}
func (l ApiLogger) Actionf(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Generatef(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Waitingf(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Successf(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Warningf(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Failuref(format string, a ...interface{}) {
l.logger.Info(fmt.Sprintf(format, a...))
}
func (l ApiLogger) Write(p []byte) (n int, err error) {
l.logger.Info(string(p))
return len(p), nil
}