jsonconsole.js
function replace() {

    if (!isOriginal) return;
    else isOriginal = false;

    function replaceWith(fn) {
        return function() {
            /* eslint prefer-rest-params:0 */
            // todo: once node v4 support dropped, use rest parameter instead
            fn.apply(logger, Array.from(arguments));
        };
    }

    ['log', 'debug', 'info', 'warn', 'error'].forEach((lvl) => {
        console[lvl] = function() {
            Array.prototype.slice.call(arguments).forEach((arg) => {
                write(lvl == "error" ? process.stderr : process.stdout, lvl, arg);
            });
        };
    });

}
function replace() {

    if (!isOriginal) return;
    else isOriginal = false;

    function replaceWith(fn) {
        return function() {
            /* eslint prefer-rest-params:0 */
            // todo: once node v4 support dropped, use rest parameter instead
            fn.apply(logger, Array.from(arguments));
        };
    }

    ['log', 'debug', 'info', 'warn', 'error'].forEach((lvl) => {
        console[lvl] = function() {
            Array.prototype.slice.call(arguments).forEach((arg) => {
                write(lvl == "error" ? process.stderr : process.stdout, lvl, arg);
            });
        };
    });

}
function replace ( ) { if ( ! isOriginal ) return ; else isOriginal = false ; function replaceWith ( fn ) { return function ( ) { /* eslint prefer-rest-params:0 */ // todo: once node v4 support dropped, use rest parameter instead fn . apply ( logger , Array . from ( arguments ) ) ; } ; } [ 'log' , 'debug' , 'info' , 'warn' , 'error' ] . forEach ( ( lvl ) => { console [ lvl ] = function ( ) { Array . prototype . slice . call ( arguments ) . forEach ( ( arg ) => { write ( lvl == "error" ? process . stderr : process . stdout , lvl , arg ) ; } ) ; } ; } ) ; }
Replace global console api
Replace global console api