From 53741ad0205351bf7b3e3175b1aa405e856cbc98 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Mon, 28 Nov 2016 13:06:28 -0800 Subject: [PATCH] Packager: Shorter + Consistent-Width Timestamps Summary: Sets some options on `toLocaleString()` so that the server debug output's timestamps are shorter and have a consistent width (zero-padded). Reviewed By: cpojer Differential Revision: D4235074 fbshipit-source-id: 72dcf35ffd182eb70afc20d2b266314787433c4a --- packager/react-packager/src/Logger/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packager/react-packager/src/Logger/index.js b/packager/react-packager/src/Logger/index.js index 11bf72f41..84fe13b6d 100644 --- a/packager/react-packager/src/Logger/index.js +++ b/packager/react-packager/src/Logger/index.js @@ -23,6 +23,16 @@ import type { LogEntry, } from './Types'; +const DATE_LOCALE_OPTIONS = { + day: '2-digit', + hour12: false, + hour: '2-digit', + minute: '2-digit', + month: '2-digit', + second: '2-digit', + year: 'numeric', +}; + let PRINT_LOG_ENTRIES = true; const log_session = `${os.hostname()}-${Date.now()}`; const eventEmitter = new EventEmitter(); @@ -95,7 +105,7 @@ function print( duration_ms: duration, } = logEntry; - const timeStamp = new Date().toLocaleString(); + const timeStamp = new Date().toLocaleString(undefined, DATE_LOCALE_OPTIONS); let logEntryString; switch (actionPhase) {