-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.go
44 lines (35 loc) · 806 Bytes
/
log.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
package logger
import "go.uber.org/zap"
// Loggerer is interface of Logger
type Loggerer interface {
Info(msg string, fields ...zap.Field)
Error(msg string, fields ...zap.Field)
}
// Logger logs
type Logger struct {
logger *zap.Logger
}
// New Logger
func New() *Logger {
logger, err := zap.NewProduction()
if err != nil {
panic(err)
}
return &Logger{
logger: logger,
}
}
// Info log
func (l *Logger) Info(msg string, fields ...zap.Field) {
l.logger.Info(msg, fields...)
}
// Error log
func (l *Logger) Error(msg string, fields ...zap.Field) {
l.logger.Error(msg, fields...)
}
// MockLogger is logger for test
type MockLogger struct{}
// Info log
func (l MockLogger) Info(msg string, fields ...zap.Field) {}
// Error log
func (l MockLogger) Error(msg string, fields ...zap.Field) {}