Q: Bind event handler to "console.log" JavaScript event 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?
try {
    //some code
} catch(e) {
    console.log("error: "+e)
}

function x(n) {
    //some code
    console.log(str)
}


A: I would override console.log (but store it in a different variable, in case we want to use it) like so: 
var nativeLog = console.log.bind(console) //store native function

console.log = function(text){ //override
    nativeLog("<<<" + text)
}

Abbreviating console.log in JavaScript
