ordered by last occurence (#21200)

This commit is contained in:
Diogo Gomes authored and Paulus Schoutsen committed 2019-02-19 08:45:21 -08:00
1 parent 99eda385d1
commit b0f317743b
2 files changed
+12 -3

No files matched your search

@@ -88,7 +88,7 @@ class LogEntry:
def __init__(self, record, stack, source):
"""Initialize a log entry."""
self.timestamp = record.created
self.first_occured = self.timestamp = record.created
self.level = record.levelname
self.message = record.getMessage()
if record.exc_info:
@@ -125,9 +125,13 @@ class DedupStore(OrderedDict):
key = str(entry.hash())
if key in self:
entry.count = self[key].count + 1
# Update stored entry
self[key].count += 1
self[key].timestamp = entry.timestamp
self[key] = entry
self.move_to_end(key)
else:
self[key] = entry
if len(self) > self.maxlen:
# Removes the first record which should also be the oldest