Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use existing 'console' overrides from PhantomJS as well.

This commit swaps the built-in 'console' object with the one defined in
'lib/console.js'. The custom object sets up proper styles for errors and
warnings.
  • Loading branch information...
commit f0f0c8dd13ad46fc1826e528989f06c4f217ed86 1 parent 98a0e6c
@StanAngeloff authored
Showing with 7 additions and 3 deletions.
  1. +1 −0  lib/inject/console.js
  2. +6 −3 lib/inject/main.js
View
1  lib/inject/console.js
View
9 lib/inject/main.js
@@ -21,6 +21,7 @@ const PADDING = ' ';
var _webpage = require('webpage'),
_ansi = require('./ansi'),
_assert = require('./assert'),
+ _console = require('./console'),
_pages = [],
_waiting = 0,
_failed, _title, _baseUri;
@@ -75,7 +76,7 @@ this.open = function open(uri, message, options, block) {
} else {
_waiting = _waiting - 1;
_failed = true;
- console.warn(_ansi.style('yellow') + "Could not open page at '" + uri + "'." + _ansi.style('reset'));
+ _console.warn("Could not open page at '" + uri + "'.");
}
}
});
@@ -95,7 +96,8 @@ this.message = function message(/* event, ...args, resume */) {
var json = JSON.parse(request.responseText);
resume.apply(resume, json);
} else {
- console.error(_ansi.style('red') + "Could not process event '" + event + "', server HTTP status code was '" + request.status + ' ' + request.statusText + "':\n" + request.responseText);
+ _console.error("Could not process event '" + event + "', server HTTP status code was '" + request.status + ' ' + request.statusText + "':");
+ _console.error(request.responseText);
phantom.exit(3);
}
};
@@ -165,6 +167,7 @@ var _interval = setInterval(function() {
}, 125);
window.onerror = function() {
- console.error(_ansi.style('red') + "Uncaught exception in '" + ${FILE:encode} + "':\n" + _ansi.style('reset') + Array.prototype.slice.call(arguments).join('; ').trim());
+ _console.error("Uncaught exception in '" + ${FILE:encode} + "':");
+ _console.error(Array.prototype.slice.call(arguments).join('; ').trim());
phantom.exit(2);
};

0 comments on commit f0f0c8d

Please sign in to comment.
Something went wrong with that request. Please try again.