Support log extras

Reviewed By: javache

Differential Revision: D2580869

fb-gh-sync-id: bd24c976aef09243cd11b408d0f37997e400d238
This commit is contained in:
Alexey Lang 2015-10-26 12:50:54 -07:00 committed by facebook-github-bot-3
parent 725de1d236
commit f87d2e15bd
1 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,7 @@
var performanceNow = require('performanceNow');
var timespans = {};
var extras = {};
/**
* This is meant to collect and log performance data in production, which means
@ -72,6 +73,7 @@ var PerformanceLogger = {
clearTimespans() {
timespans = {};
extras = {};
},
getTimespans() {
@ -99,6 +101,23 @@ var PerformanceLogger = {
label
);
}
},
setExtra(key, value) {
if (extras[key]) {
if (__DEV__) {
console.log(
'PerformanceLogger: Attempting to set an extra that already exists ',
key
);
}
return;
}
extras[key] = value;
},
getExtras() {
return extras;
}
};