Port CatalystLoggingTestCase to iOS

Reviewed By: nicklockwood

Differential Revision: D2658485

fb-gh-sync-id: e6803aefee69ee058651fc4c8c202619543f0cd2
This commit is contained in:
Pieter De Baets 2015-11-20 03:33:07 -08:00 committed by facebook-github-bot-7
parent 4ddb158c72
commit b289600a7a
1 changed files with 13 additions and 7 deletions

View File

@ -366,7 +366,6 @@
};
function setupConsole(global) {
var originalConsole = global.console;
if (!global.nativeLoggingHook) {
@ -375,16 +374,23 @@
function getNativeLogFunction(level) {
return function() {
var str = Array.prototype.map.call(arguments, function(arg) {
var str;
if (arguments.length === 1 && typeof arguments[0] === 'string') {
str = arguments[0];
} else {
str = Array.prototype.map.call(arguments, function(arg) {
return inspect(arg, {depth: 10});
}).join(', ');
if (str.slice(0, 10) === "'Warning: " && level >= LOG_LEVELS.error) {
}
var logLevel = level;
if (str.slice(0, 9) === 'Warning: ' && logLevel >= LOG_LEVELS.error) {
// React warnings use console.error so that a stack trace is shown,
// but we don't (currently) want these to show a redbox
// (Note: Logic duplicated in ExceptionsManager.js.)
level = LOG_LEVELS.warn;
logLevel = LOG_LEVELS.warn;
}
global.nativeLoggingHook(str, level);
global.nativeLoggingHook(str, logLevel);
};
}