-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from cloudfoundry/flush-log-messages
Fix inter-woven output during start
- Loading branch information
Showing
4 changed files
with
201 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,118 @@ | ||
// This file was generated by counterfeiter | ||
package fakes | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/cloudfoundry/cli/cf/api" | ||
"github.com/cloudfoundry/loggregatorlib/logmessage" | ||
) | ||
|
||
type FakeLogsRepository struct { | ||
AppLoggedGuid string | ||
RecentLogs []*logmessage.LogMessage | ||
RecentLogErr error | ||
|
||
TailLogMessages []*logmessage.LogMessage | ||
TailLogErr error | ||
|
||
TailLogStopCalled bool | ||
RecentLogsForStub func(appGuid string) ([]*logmessage.LogMessage, error) | ||
recentLogsForMutex sync.RWMutex | ||
recentLogsForArgsForCall []struct { | ||
appGuid string | ||
} | ||
recentLogsForReturns struct { | ||
result1 []*logmessage.LogMessage | ||
result2 error | ||
} | ||
TailLogsForStub func(appGuid string, onConnect func(), onMessage func(*logmessage.LogMessage)) error | ||
tailLogsForMutex sync.RWMutex | ||
tailLogsForArgsForCall []struct { | ||
appGuid string | ||
onConnect func() | ||
onMessage func(*logmessage.LogMessage) | ||
} | ||
tailLogsForReturns struct { | ||
result1 error | ||
} | ||
CloseStub func() | ||
closeMutex sync.RWMutex | ||
closeArgsForCall []struct{} | ||
} | ||
|
||
func (l *FakeLogsRepository) RecentLogsFor(appGuid string) ([]*logmessage.LogMessage, error) { | ||
l.AppLoggedGuid = appGuid | ||
return l.RecentLogs, l.RecentLogErr | ||
func (fake *FakeLogsRepository) RecentLogsFor(appGuid string) ([]*logmessage.LogMessage, error) { | ||
fake.recentLogsForMutex.Lock() | ||
defer fake.recentLogsForMutex.Unlock() | ||
fake.recentLogsForArgsForCall = append(fake.recentLogsForArgsForCall, struct { | ||
appGuid string | ||
}{appGuid}) | ||
if fake.RecentLogsForStub != nil { | ||
return fake.RecentLogsForStub(appGuid) | ||
} else { | ||
return fake.recentLogsForReturns.result1, fake.recentLogsForReturns.result2 | ||
} | ||
} | ||
|
||
func (l *FakeLogsRepository) TailLogsFor(appGuid string, onConnect func(), onMessage func(*logmessage.LogMessage)) (err error) { | ||
l.AppLoggedGuid = appGuid | ||
func (fake *FakeLogsRepository) RecentLogsForCallCount() int { | ||
fake.recentLogsForMutex.RLock() | ||
defer fake.recentLogsForMutex.RUnlock() | ||
return len(fake.recentLogsForArgsForCall) | ||
} | ||
|
||
err = l.TailLogErr | ||
if err != nil { | ||
return | ||
} | ||
func (fake *FakeLogsRepository) RecentLogsForArgsForCall(i int) string { | ||
fake.recentLogsForMutex.RLock() | ||
defer fake.recentLogsForMutex.RUnlock() | ||
return fake.recentLogsForArgsForCall[i].appGuid | ||
} | ||
|
||
onConnect() | ||
func (fake *FakeLogsRepository) RecentLogsForReturns(result1 []*logmessage.LogMessage, result2 error) { | ||
fake.RecentLogsForStub = nil | ||
fake.recentLogsForReturns = struct { | ||
result1 []*logmessage.LogMessage | ||
result2 error | ||
}{result1, result2} | ||
} | ||
|
||
for _, msg := range l.TailLogMessages { | ||
onMessage(msg) | ||
func (fake *FakeLogsRepository) TailLogsFor(appGuid string, onConnect func(), onMessage func(*logmessage.LogMessage)) error { | ||
fake.tailLogsForMutex.Lock() | ||
defer fake.tailLogsForMutex.Unlock() | ||
fake.tailLogsForArgsForCall = append(fake.tailLogsForArgsForCall, struct { | ||
appGuid string | ||
onConnect func() | ||
onMessage func(*logmessage.LogMessage) | ||
}{appGuid, onConnect, onMessage}) | ||
if fake.TailLogsForStub != nil { | ||
return fake.TailLogsForStub(appGuid, onConnect, onMessage) | ||
} else { | ||
return fake.tailLogsForReturns.result1 | ||
} | ||
} | ||
|
||
return | ||
func (fake *FakeLogsRepository) TailLogsForCallCount() int { | ||
fake.tailLogsForMutex.RLock() | ||
defer fake.tailLogsForMutex.RUnlock() | ||
return len(fake.tailLogsForArgsForCall) | ||
} | ||
|
||
func (l *FakeLogsRepository) Close() { | ||
l.TailLogStopCalled = true | ||
func (fake *FakeLogsRepository) TailLogsForArgsForCall(i int) (string, func(), func(*logmessage.LogMessage)) { | ||
fake.tailLogsForMutex.RLock() | ||
defer fake.tailLogsForMutex.RUnlock() | ||
return fake.tailLogsForArgsForCall[i].appGuid, fake.tailLogsForArgsForCall[i].onConnect, fake.tailLogsForArgsForCall[i].onMessage | ||
} | ||
|
||
func (l *FakeLogsRepository) logsFor(appGuid string, logMessages []*logmessage.LogMessage, onConnect func(), logChan chan *logmessage.LogMessage, stopLoggingChan chan bool) { | ||
l.AppLoggedGuid = appGuid | ||
onConnect() | ||
func (fake *FakeLogsRepository) TailLogsForReturns(result1 error) { | ||
fake.TailLogsForStub = nil | ||
fake.tailLogsForReturns = struct { | ||
result1 error | ||
}{result1} | ||
} | ||
|
||
for _, logMsg := range logMessages { | ||
logChan <- logMsg | ||
func (fake *FakeLogsRepository) Close() { | ||
fake.closeMutex.Lock() | ||
defer fake.closeMutex.Unlock() | ||
fake.closeArgsForCall = append(fake.closeArgsForCall, struct{}{}) | ||
if fake.CloseStub != nil { | ||
fake.CloseStub() | ||
} | ||
} | ||
|
||
go func() { | ||
l.TailLogStopCalled = <-stopLoggingChan | ||
}() | ||
|
||
return | ||
func (fake *FakeLogsRepository) CloseCallCount() int { | ||
fake.closeMutex.RLock() | ||
defer fake.closeMutex.RUnlock() | ||
return len(fake.closeArgsForCall) | ||
} | ||
|
||
var _ api.LogsRepository = new(FakeLogsRepository) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.