Fix debug log growing uncontrollably
Races between adding new log entries and fetching old ones can cause an overage of more than one entry. // FREEBIE
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
},
|
||||
log: function(str) {
|
||||
this.add({time: Date.now(), value: str}).save();
|
||||
if (this.length > MAX_MESSAGES) {
|
||||
while (this.length > MAX_MESSAGES) {
|
||||
this.at(0).destroy();
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user