From 459c2e5ef3ea59c7783986795651729acee977ba Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 27 Apr 2017 15:54:55 +0300 Subject: [PATCH] update log timestamp adjustments --- update.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/update.js b/update.js index ec7b9641..f71ed5e0 100644 --- a/update.js +++ b/update.js @@ -132,19 +132,17 @@ var updater = { let queue = []; let lastWriteTime = 0; return text => { - queue.push(text); + queue.push({text, time: new Date().toLocaleString()}); debounce(flushQueue, 1e3); }; function flushQueue() { chromeLocal.getValue('updateLog').then((lines = []) => { - // our XHR timeout is 10 seconds - const time = performance.now() - lastWriteTime > 11e3 - ? new Date().toLocaleString() + '\t' - : ''; + const time = Date.now() - lastWriteTime > 11e3 ? queue[0].time + ' ' : ''; lines.splice(0, lines.length - 1000); - lines.push(...queue.map(item => item ? time + item : '')); + lines.push(time + queue[0].text); + lines.push(...queue.slice(1).map(item => item.text)); chromeLocal.setValue('updateLog', lines); - lastWriteTime = performance.now(); + lastWriteTime = Date.now(); queue = []; }); }