-
Notifications
You must be signed in to change notification settings - Fork 0
/
loggerStub.go
70 lines (59 loc) · 1.63 KB
/
loggerStub.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
package testscommon
import logger "github.com/bhagyaraj1208117/andes-logger-xyz"
// LoggerStub -
type LoggerStub struct {
TraceCalled func(message string, args ...interface{})
DebugCalled func(message string, args ...interface{})
InfoCalled func(message string, args ...interface{})
WarnCalled func(message string, args ...interface{})
ErrorCalled func(message string, args ...interface{})
LogIfErrorCalled func(err error, args ...interface{})
GetLevelCalled func() logger.LogLevel
}
// Trace -
func (stub *LoggerStub) Trace(message string, args ...interface{}) {
if stub.TraceCalled != nil {
stub.TraceCalled(message, args)
}
}
// Debug -
func (stub *LoggerStub) Debug(message string, args ...interface{}) {
if stub.DebugCalled != nil {
stub.DebugCalled(message, args)
}
}
// Info -
func (stub *LoggerStub) Info(message string, args ...interface{}) {
if stub.InfoCalled != nil {
stub.InfoCalled(message, args)
}
}
// Warn -
func (stub *LoggerStub) Warn(message string, args ...interface{}) {
if stub.WarnCalled != nil {
stub.WarnCalled(message, args)
}
}
// Error -
func (stub *LoggerStub) Error(message string, args ...interface{}) {
if stub.ErrorCalled != nil {
stub.ErrorCalled(message, args)
}
}
// LogIfError -
func (stub *LoggerStub) LogIfError(err error, args ...interface{}) {
if stub.LogIfErrorCalled != nil {
stub.LogIfErrorCalled(err, args)
}
}
// GetLevel -
func (stub *LoggerStub) GetLevel() logger.LogLevel {
if stub.GetLevelCalled != nil {
return stub.GetLevelCalled()
}
return logger.LogTrace
}
// IsInterfaceNil -
func (stub *LoggerStub) IsInterfaceNil() bool {
return false
}