github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/flogging/mock/observer.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hyperledger/fabric/common/flogging" 8 "go.uber.org/zap/zapcore" 9 ) 10 11 type Observer struct { 12 CheckStub func(zapcore.Entry, *zapcore.CheckedEntry) 13 checkMutex sync.RWMutex 14 checkArgsForCall []struct { 15 arg1 zapcore.Entry 16 arg2 *zapcore.CheckedEntry 17 } 18 WriteEntryStub func(zapcore.Entry, []zapcore.Field) 19 writeEntryMutex sync.RWMutex 20 writeEntryArgsForCall []struct { 21 arg1 zapcore.Entry 22 arg2 []zapcore.Field 23 } 24 invocations map[string][][]interface{} 25 invocationsMutex sync.RWMutex 26 } 27 28 func (fake *Observer) Check(arg1 zapcore.Entry, arg2 *zapcore.CheckedEntry) { 29 fake.checkMutex.Lock() 30 fake.checkArgsForCall = append(fake.checkArgsForCall, struct { 31 arg1 zapcore.Entry 32 arg2 *zapcore.CheckedEntry 33 }{arg1, arg2}) 34 fake.recordInvocation("Check", []interface{}{arg1, arg2}) 35 fake.checkMutex.Unlock() 36 if fake.CheckStub != nil { 37 fake.CheckStub(arg1, arg2) 38 } 39 } 40 41 func (fake *Observer) CheckCallCount() int { 42 fake.checkMutex.RLock() 43 defer fake.checkMutex.RUnlock() 44 return len(fake.checkArgsForCall) 45 } 46 47 func (fake *Observer) CheckCalls(stub func(zapcore.Entry, *zapcore.CheckedEntry)) { 48 fake.checkMutex.Lock() 49 defer fake.checkMutex.Unlock() 50 fake.CheckStub = stub 51 } 52 53 func (fake *Observer) CheckArgsForCall(i int) (zapcore.Entry, *zapcore.CheckedEntry) { 54 fake.checkMutex.RLock() 55 defer fake.checkMutex.RUnlock() 56 argsForCall := fake.checkArgsForCall[i] 57 return argsForCall.arg1, argsForCall.arg2 58 } 59 60 func (fake *Observer) WriteEntry(arg1 zapcore.Entry, arg2 []zapcore.Field) { 61 var arg2Copy []zapcore.Field 62 if arg2 != nil { 63 arg2Copy = make([]zapcore.Field, len(arg2)) 64 copy(arg2Copy, arg2) 65 } 66 fake.writeEntryMutex.Lock() 67 fake.writeEntryArgsForCall = append(fake.writeEntryArgsForCall, struct { 68 arg1 zapcore.Entry 69 arg2 []zapcore.Field 70 }{arg1, arg2Copy}) 71 fake.recordInvocation("WriteEntry", []interface{}{arg1, arg2Copy}) 72 fake.writeEntryMutex.Unlock() 73 if fake.WriteEntryStub != nil { 74 fake.WriteEntryStub(arg1, arg2) 75 } 76 } 77 78 func (fake *Observer) WriteEntryCallCount() int { 79 fake.writeEntryMutex.RLock() 80 defer fake.writeEntryMutex.RUnlock() 81 return len(fake.writeEntryArgsForCall) 82 } 83 84 func (fake *Observer) WriteEntryCalls(stub func(zapcore.Entry, []zapcore.Field)) { 85 fake.writeEntryMutex.Lock() 86 defer fake.writeEntryMutex.Unlock() 87 fake.WriteEntryStub = stub 88 } 89 90 func (fake *Observer) WriteEntryArgsForCall(i int) (zapcore.Entry, []zapcore.Field) { 91 fake.writeEntryMutex.RLock() 92 defer fake.writeEntryMutex.RUnlock() 93 argsForCall := fake.writeEntryArgsForCall[i] 94 return argsForCall.arg1, argsForCall.arg2 95 } 96 97 func (fake *Observer) Invocations() map[string][][]interface{} { 98 fake.invocationsMutex.RLock() 99 defer fake.invocationsMutex.RUnlock() 100 fake.checkMutex.RLock() 101 defer fake.checkMutex.RUnlock() 102 fake.writeEntryMutex.RLock() 103 defer fake.writeEntryMutex.RUnlock() 104 copiedInvocations := map[string][][]interface{}{} 105 for key, value := range fake.invocations { 106 copiedInvocations[key] = value 107 } 108 return copiedInvocations 109 } 110 111 func (fake *Observer) recordInvocation(key string, args []interface{}) { 112 fake.invocationsMutex.Lock() 113 defer fake.invocationsMutex.Unlock() 114 if fake.invocations == nil { 115 fake.invocations = map[string][][]interface{}{} 116 } 117 if fake.invocations[key] == nil { 118 fake.invocations[key] = [][]interface{}{} 119 } 120 fake.invocations[key] = append(fake.invocations[key], args) 121 } 122 123 var _ flogging.Observer = new(Observer)