From 6b89d1ca978839911c2d1147483b8e34cd099d1c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 11 Feb 2016 00:30:34 -0800 Subject: [PATCH] Fixed timestamp bug --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index d5be3f8..bdea44e 100644 --- a/src/index.js +++ b/src/index.js @@ -57,7 +57,7 @@ function createLogger(options = {}) { const logBuffer = []; function printBuffer() { logBuffer.forEach((logEntry, key) => { - const { started, action, prevState, error } = logEntry; + const { started, startedTime, action, prevState, error } = logEntry; let { took, nextState } = logEntry; const nextEntry = logBuffer[key + 1]; if (nextEntry) { @@ -66,10 +66,9 @@ function createLogger(options = {}) { } // message const formattedAction = actionTransformer(action); - const time = new Date(started); const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action) : collapsed; - const formattedTime = formatTime(time); + const formattedTime = formatTime(startedTime); const titleCSS = colors.title ? `color: ${colors.title(formattedAction)};` : null; const title = `action ${formattedAction.type}${timestamp ? formattedTime : ``}${duration ? ` in ${took.toFixed(2)} ms` : ``}`; @@ -119,6 +118,7 @@ function createLogger(options = {}) { logBuffer.push(logEntry); logEntry.started = timer.now(); + logEntry.startedTime = new Date(); logEntry.prevState = stateTransformer(getState()); logEntry.action = action;