mirror of https://github.com/status-im/metro.git
Port CatalystLoggingTestCase to iOS
Reviewed By: nicklockwood Differential Revision: D2658485 fb-gh-sync-id: e6803aefee69ee058651fc4c8c202619543f0cd2
This commit is contained in:
parent
4ddb158c72
commit
b289600a7a
|
@ -366,7 +366,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
function setupConsole(global) {
|
function setupConsole(global) {
|
||||||
|
|
||||||
var originalConsole = global.console;
|
var originalConsole = global.console;
|
||||||
|
|
||||||
if (!global.nativeLoggingHook) {
|
if (!global.nativeLoggingHook) {
|
||||||
|
@ -375,16 +374,23 @@
|
||||||
|
|
||||||
function getNativeLogFunction(level) {
|
function getNativeLogFunction(level) {
|
||||||
return function() {
|
return function() {
|
||||||
var str = Array.prototype.map.call(arguments, function(arg) {
|
var str;
|
||||||
return inspect(arg, {depth: 10});
|
if (arguments.length === 1 && typeof arguments[0] === 'string') {
|
||||||
}).join(', ');
|
str = arguments[0];
|
||||||
if (str.slice(0, 10) === "'Warning: " && level >= LOG_LEVELS.error) {
|
} else {
|
||||||
|
str = Array.prototype.map.call(arguments, function(arg) {
|
||||||
|
return inspect(arg, {depth: 10});
|
||||||
|
}).join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
// React warnings use console.error so that a stack trace is shown,
|
||||||
// but we don't (currently) want these to show a redbox
|
// but we don't (currently) want these to show a redbox
|
||||||
// (Note: Logic duplicated in ExceptionsManager.js.)
|
// (Note: Logic duplicated in ExceptionsManager.js.)
|
||||||
level = LOG_LEVELS.warn;
|
logLevel = LOG_LEVELS.warn;
|
||||||
}
|
}
|
||||||
global.nativeLoggingHook(str, level);
|
global.nativeLoggingHook(str, logLevel);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue