From c31fa2a45dcd9e46097720d618bbbd46dc0ecfcb Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Thu, 4 Jul 2019 02:50:58 -0700 Subject: [PATCH] Do not show setup logs from `createPerformanceLogger` unless logs are enabled for it Summary: This module logs helpful messages in `__DEV__` but it only logs actionable performance logs when the flag on top of the file is enabled. This diff changes those to only log when the toggle on top of the file is enabled as well. Reviewed By: gaearon Differential Revision: D16107933 fbshipit-source-id: 7671bc521af984d617a0f5ffc0eacd1aa5674a62 --- Libraries/Utilities/createPerformanceLogger.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/Utilities/createPerformanceLogger.js b/Libraries/Utilities/createPerformanceLogger.js index 2f49f988c15..ff7879bec91 100644 --- a/Libraries/Utilities/createPerformanceLogger.js +++ b/Libraries/Utilities/createPerformanceLogger.js @@ -67,7 +67,7 @@ function createPerformanceLogger(): IPerformanceLogger { addTimespan(key: string, lengthInMs: number, description?: string) { if (this._timespans[key]) { - if (__DEV__) { + if (PRINT_TO_CONSOLE && __DEV__) { infoLog( 'PerformanceLogger: Attempting to add a timespan that already exists ', key, @@ -84,7 +84,7 @@ function createPerformanceLogger(): IPerformanceLogger { startTimespan(key: string, description?: string) { if (this._timespans[key]) { - if (__DEV__) { + if (PRINT_TO_CONSOLE && __DEV__) { infoLog( 'PerformanceLogger: Attempting to start a timespan that already exists ', key, @@ -106,7 +106,7 @@ function createPerformanceLogger(): IPerformanceLogger { stopTimespan(key: string) { const timespan = this._timespans[key]; if (!timespan || !timespan.startTime) { - if (__DEV__) { + if (PRINT_TO_CONSOLE && __DEV__) { infoLog( 'PerformanceLogger: Attempting to end a timespan that has not started ', key, @@ -115,7 +115,7 @@ function createPerformanceLogger(): IPerformanceLogger { return; } if (timespan.endTime) { - if (__DEV__) { + if (PRINT_TO_CONSOLE && __DEV__) { infoLog( 'PerformanceLogger: Attempting to end a timespan that has already ended ', key, @@ -203,7 +203,7 @@ function createPerformanceLogger(): IPerformanceLogger { setExtra(key: string, value: any) { if (this._extras[key]) { - if (__DEV__) { + if (PRINT_TO_CONSOLE && __DEV__) { infoLog( 'PerformanceLogger: Attempting to set an extra that already exists ', {key, currentValue: this._extras[key], attemptedValue: value}, @@ -230,7 +230,7 @@ function createPerformanceLogger(): IPerformanceLogger { markPoint(key: string, timestamp?: number) { if (this._points[key]) { - if (__DEV__) { + if (PRINT_TO_CONSOLE && __DEV__) { infoLog( 'PerformanceLogger: Attempting to mark a point that has been already logged ', key,