Bind event handler to "console.log" JavaScript event <p>My script sends text to the console output from several places in Javascript (see examples), how do I bind an event handler function to the log function itself so that a function is executed each time the event is triggered?</p> <pre><code>try { //some code } catch(e) { console.log("error: "+e) } function x(n) { //some code console.log(str) } </code></pre>