Skip to content

Commit

Permalink
fix(android): don't patch console object (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Sep 25, 2019
1 parent 6a4de97 commit 8964a4a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions core/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
win.console.warn('Advance console logging disabled.')
}

// patch window.console and store original console fns
var orgConsole = {};
// patch window.console on iOS and store original console fns
var orgConsole = capacitor.isIOS ? {} : win.console;

// list log functions bridged to native log
var bridgedLevels = {
Expand All @@ -66,12 +66,11 @@
trace: true,
warn: true,
};

Object.keys(win.console).forEach(function (level) {
if (typeof win.console[level] === 'function') {
// loop through all the console functions and keep references to the original
orgConsole[level] = win.console[level];
if (capacitor.isIOS) {
if (capacitor.isIOS) {
Object.keys(win.console).forEach(function (level) {
if (typeof win.console[level] === 'function') {
// loop through all the console functions and keep references to the original
orgConsole[level] = win.console[level];
win.console[level] = function capacitorConsole() {
var msgs = Array.prototype.slice.call(arguments);

Expand Down Expand Up @@ -102,8 +101,8 @@
}
};
}
}
});
});
}

function addLegacyHandlers(win) {
win.navigator.app = {
Expand Down Expand Up @@ -348,7 +347,7 @@
capacitor.handleError = function(error) {
console.error(error);
}

capacitor.handleWindowError = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
Expand Down

0 comments on commit 8964a4a

Please sign in to comment.