I'm trying to figure out how to capture stderr and stdout in the browser from the currently executing javascript.
This will be for a live code editor.
I'm trying to figure out how to capture stderr and stdout in the browser from the currently executing javascript.
This will be for a live code editor.
JS has no stdout
or stderr
- it just has the console
.
It is possible to override console.log()
with your own function that does whatever processing you want, and ideally then pass the log message to the original console.log
function. Ditto for console.error
.
For example:
(function() {
const log_orig = console.log;
console.log = function() {
log_orig.call(console, 'log called with ' arguments.length + ' parameters');
log_orig.apply(console, arguments);
}
})(); // IIFE
You can't.
Any output and errors that browser outputs are not exposed to JS.