This commit is contained in:
Stef Heyenrath
2019-08-23 11:38:29 +00:00
committed by GitHub
parent fc64c5f925
commit 2e33bcc464

View File

@@ -162,10 +162,9 @@ namespace WireMock.Owin
if (_options.MaxRequestLogCount != null) if (_options.MaxRequestLogCount != null)
{ {
var amount = _options.LogEntries.Count - _options.MaxRequestLogCount.Value; foreach (var logEntry in _options.LogEntries.OrderBy(le => le.RequestMessage.DateTime).Take(_options.LogEntries.Count - _options.MaxRequestLogCount.Value).ToList())
for (int i = 0; i < amount; i++)
{ {
_options.LogEntries.RemoveAt(0); _options.LogEntries.Remove(logEntry);
} }
} }
@@ -173,13 +172,9 @@ namespace WireMock.Owin
{ {
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value); 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]; _options.LogEntries.Remove(logEntry);
if (le.RequestMessage.DateTime <= checkTime)
{
_options.LogEntries.RemoveAt(i);
}
} }
} }
} }