This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
logger.go
78 lines (64 loc) · 1.46 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
75
76
77
78
package mocks
import (
"code.cloudfoundry.org/lager"
"sync"
)
type MockLogger struct {
logs map[lager.LogLevel][]Log
mutex sync.Mutex
}
type Log struct {
Action string
Err error
Data []lager.Data
}
func NewMockLogger() *MockLogger {
return &MockLogger{
logs: make(map[lager.LogLevel][]Log),
}
}
func (m *MockLogger) RegisterSink(lager.Sink) {
panic("Not implemented")
}
func (m *MockLogger) Session(task string, data ...lager.Data) lager.Logger {
panic("Not implemented")
}
func (m *MockLogger) SessionName() string {
panic("Not implemented")
}
func (m *MockLogger) Debug(action string, data ...lager.Data) {
m.mutex.Lock()
m.logs[lager.DEBUG] = append(m.logs[lager.DEBUG], Log{
Action: action,
Data: data,
})
m.mutex.Unlock()
}
func (m *MockLogger) Info(action string, data ...lager.Data) {
m.mutex.Lock()
m.logs[lager.INFO] = append(m.logs[lager.INFO], Log{
Action: action,
Data: data,
})
m.mutex.Unlock()
}
func (m *MockLogger) Error(action string, err error, data ...lager.Data) {
m.mutex.Lock()
m.logs[lager.ERROR] = append(m.logs[lager.ERROR], Log{
Action: action,
Err: err,
Data: data,
})
m.mutex.Unlock()
}
func (m *MockLogger) Fatal(action string, err error, data ...lager.Data) {
panic("Not implemented")
}
func (m *MockLogger) WithData(lager.Data) lager.Logger {
panic("Not implemented")
}
func (m *MockLogger) GetLogs(level lager.LogLevel) []Log {
m.mutex.Lock()
defer m.mutex.Unlock()
return m.logs[level]
}