Count console.log objects

If you just want to override console.log to print the count of responses, this should do it, but this will increment the count for any console.log call.

var logCount = 0

console.log = function (logMessage) {
    var logger = document.getElementById('log');
    logCount++;
    logger.innerHTML = logCount;
}

If you want to count on responses and not all console logs, use something like this

var logCount = 0

function logHttpResponse(response) {
    var logger = document.getElementById('log');
    logCount++;
    logger.innerHTML = logCount;
}

Leave a Comment