From 0f6762ba50b92a16fa11f10142b4416aace57f5e Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Mon, 30 Apr 2018 11:41:14 -0700 Subject: [PATCH] improve console logging Summary: * Always log when PRINT_TO_CONSOLE true - o reason to also check DEV. * Log when `clearExceptTimespans` is called. * Type `PRINT_TO_CONSOLE: false` to prevent accidental commits setting it true. Reviewed By: alexeylang Differential Revision: D7816623 fbshipit-source-id: 47cf7e158133045e20b345139efb1a79e5e6553b --- Libraries/Utilities/PerformanceLogger.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Libraries/Utilities/PerformanceLogger.js b/Libraries/Utilities/PerformanceLogger.js index aa4633fce..a48f1adb4 100644 --- a/Libraries/Utilities/PerformanceLogger.js +++ b/Libraries/Utilities/PerformanceLogger.js @@ -29,7 +29,7 @@ let timespans: {[key: string]: Timespan} = {}; let extras: {[key: string]: any} = {}; const cookies: {[key: string]: number} = {}; -const PRINT_TO_CONSOLE = false; +const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally committing `true`; /** * This is meant to collect and log performance data in production, which means @@ -69,7 +69,7 @@ const PerformanceLogger = { startTime: performanceNow(), }; cookies[key] = Systrace.beginAsyncEvent(key); - if (__DEV__ && PRINT_TO_CONSOLE) { + if (PRINT_TO_CONSOLE) { infoLog('PerformanceLogger.js', 'start: ' + key); } }, @@ -97,7 +97,7 @@ const PerformanceLogger = { timespan.endTime = performanceNow(); timespan.totalTime = timespan.endTime - (timespan.startTime || 0); - if (__DEV__ && PRINT_TO_CONSOLE) { + if (PRINT_TO_CONSOLE) { infoLog('PerformanceLogger.js', 'end: ' + key); } @@ -108,7 +108,7 @@ const PerformanceLogger = { clear() { timespans = {}; extras = {}; - if (__DEV__ && PRINT_TO_CONSOLE) { + if (PRINT_TO_CONSOLE) { infoLog('PerformanceLogger.js', 'clear'); } }, @@ -120,7 +120,7 @@ const PerformanceLogger = { } } extras = {}; - if (__DEV__ && PRINT_TO_CONSOLE) { + if (PRINT_TO_CONSOLE) { infoLog('PerformanceLogger.js', 'clearCompleted'); } }, @@ -133,6 +133,9 @@ const PerformanceLogger = { return previous; }, {}); extras = {}; + if (PRINT_TO_CONSOLE) { + infoLog('PerformanceLogger.js', 'clearExceptTimespans', keys); + } }, currentTimestamp() {