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
This commit is contained in:
parent
5b923e0eaf
commit
0f6762ba50
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue