Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Aug 23, 2019
1 parent fc64c5f commit 2e33bcc
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/WireMock.Net/Owin/WireMockMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,19 @@ private void LogRequest(LogEntry entry, bool addRequest)

if (_options.MaxRequestLogCount != null)
{
var amount = _options.LogEntries.Count - _options.MaxRequestLogCount.Value;
for (int i = 0; i < amount; i++)
foreach (var logEntry in _options.LogEntries.OrderBy(le => le.RequestMessage.DateTime).Take(_options.LogEntries.Count - _options.MaxRequestLogCount.Value).ToList())
{
_options.LogEntries.RemoveAt(0);
_options.LogEntries.Remove(logEntry);
}
}

if (_options.RequestLogExpirationDuration != null)
{
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value);

for (var i = _options.LogEntries.Count - 1; i >= 0; i--)
foreach (var logEntry in _options.LogEntries.Where(le => le.RequestMessage.DateTime < checkTime).ToList())
{
var le = _options.LogEntries[i];
if (le.RequestMessage.DateTime <= checkTime)
{
_options.LogEntries.RemoveAt(i);
}
_options.LogEntries.Remove(logEntry);
}
}
}
Expand Down

0 comments on commit 2e33bcc

Please sign in to comment.