src/js/helpers/Logger.js
function Logger(ctx) {
    _console = window ? window.console : {};
    _global = window ? window : {};
    this._timers = {};
    this.args = function(context, level, args) {
        let logHeader = '%c '+level+' %c'+(new Date().toISOString())+' %c'+context;
        const colors = [_bc+_c1, _bc+_c2, _bc+_c3];
        for (let i = 0; i < args.length; i++) {
            if (typeof args[i] == 'string' && args[i].indexOf('timer:') === 0) {
                const t = args[i].split(':');
                if (t.length === 3) {
                    let elapsed;
                    switch (t[2]) {
                        case 'start':
                            this._timers[t[1]] = new Date().getTime();
                            logHeader += ' %cSTART '+t[1];
                            colors.push(_bc+_c_start);
                            break;
                        case 'stop':
                            elapsed = (new Date().getTime() - this._timers[t[1]]);
                            logHeader += ' %cSTOP '+t[1]+' '+elapsed+' ms';
                            if (elapsed > 200) {
                                colors.push(_bc+_c_end_very_slow);
                            } else if (elapsed > 100) {
                                colors.push(_bc+_c_end_slow);
                            } else {
                                colors.push(_bc+_c_end);
                            }
                            break;
                    }
                }
            }
        }
        logHeader += ' \n%c '; colors.push(_bt+'color:inherit;');
        // if (typeof args[0] == 'string') {
        //     logHeader += ' %c' + args[0];
        //     Array.prototype.shift.call(args);
        // }
        for (let c = colors.length-1; c >= 0; c--) {
            Array.prototype.unshift.call(args, colors[c]);
        }
        Array.prototype.unshift.call(args, logHeader);
        Array.prototype.push.call(args, '\n\n');
    };
    this.log = function(level, args) {
        if (typeof _callback === 'function') {
            _callback.call(ctx, level, args);
        }
        // route event
        if (!_global.zuixNoConsoleOutput) {
            this.args(ctx, level, args);
            _console.log.apply(_console, args);
        }
    };
}
function Logger(ctx) {
    _console = window ? window.console : {};
    _global = window ? window : {};
    this._timers = {};
    this.args = function(context, level, args) {
        let logHeader = '%c '+level+' %c'+(new Date().toISOString())+' %c'+context;
        const colors = [_bc+_c1, _bc+_c2, _bc+_c3];
        for (let i = 0; i < args.length; i++) {
            if (typeof args[i] == 'string' && args[i].indexOf('timer:') === 0) {
                const t = args[i].split(':');
                if (t.length === 3) {
                    let elapsed;
                    switch (t[2]) {
                        case 'start':
                            this._timers[t[1]] = new Date().getTime();
                            logHeader += ' %cSTART '+t[1];
                            colors.push(_bc+_c_start);
                            break;
                        case 'stop':
                            elapsed = (new Date().getTime() - this._timers[t[1]]);
                            logHeader += ' %cSTOP '+t[1]+' '+elapsed+' ms';
                            if (elapsed > 200) {
                                colors.push(_bc+_c_end_very_slow);
                            } else if (elapsed > 100) {
                                colors.push(_bc+_c_end_slow);
                            } else {
                                colors.push(_bc+_c_end);
                            }
                            break;
                    }
                }
            }
        }
        logHeader += ' \n%c '; colors.push(_bt+'color:inherit;');
        // if (typeof args[0] == 'string') {
        //     logHeader += ' %c' + args[0];
        //     Array.prototype.shift.call(args);
        // }
        for (let c = colors.length-1; c >= 0; c--) {
            Array.prototype.unshift.call(args, colors[c]);
        }
        Array.prototype.unshift.call(args, logHeader);
        Array.prototype.push.call(args, '\n\n');
    };
    this.log = function(level, args) {
        if (typeof _callback === 'function') {
            _callback.call(ctx, level, args);
        }
        // route event
        if (!_global.zuixNoConsoleOutput) {
            this.args(ctx, level, args);
            _console.log.apply(_console, args);
        }
    };
}
function Logger ( ctx ) { _console = window ? window . console : { } ; _global = window ? window : { } ; this . _timers = { } ; this . args = function ( context , level , args ) { let logHeader = '%c ' + level + ' %c' + ( new Date ( ) . toISOString ( ) ) + ' %c' + context ; const colors = [ _bc + _c1 , _bc + _c2 , _bc + _c3 ] ; for ( let i = 0 ; i < args . length ; i ++ ) { if ( typeof args [ i ] == 'string' && args [ i ] . indexOf ( 'timer:' ) === 0 ) { const t = args [ i ] . split ( ':' ) ; if ( t . length === 3 ) { let elapsed ; switch ( t [ 2 ] ) { case 'start' : this . _timers [ t [ 1 ] ] = new Date ( ) . getTime ( ) ; logHeader += ' %cSTART ' + t [ 1 ] ; colors . push ( _bc + _c_start ) ; break ; case 'stop' : elapsed = ( new Date ( ) . getTime ( ) - this . _timers [ t [ 1 ] ] ) ; logHeader += ' %cSTOP ' + t [ 1 ] + ' ' + elapsed + ' ms' ; if ( elapsed > 200 ) { colors . push ( _bc + _c_end_very_slow ) ; } else if ( elapsed > 100 ) { colors . push ( _bc + _c_end_slow ) ; } else { colors . push ( _bc + _c_end ) ; } break ; } } } } logHeader += ' \n%c ' ; colors . push ( _bt + 'color:inherit;' ) ; // if (typeof args[0] == 'string') { //     logHeader += ' %c' + args[0]; //     Array.prototype.shift.call(args); // } for ( let c = colors . length - 1 ; c >= 0 ; c -- ) { Array . prototype . unshift . call ( args , colors [ c ] ) ; } Array . prototype . unshift . call ( args , logHeader ) ; Array . prototype . push . call ( args , '\n\n' ) ; } ; this . log = function ( level , args ) { if ( typeof _callback === 'function' ) { _callback . call ( ctx , level , args ) ; } // route event if ( ! _global . zuixNoConsoleOutput ) { this . args ( ctx , level , args ) ; _console . log . apply ( _console , args ) ; } } ; }
Simple Logging Helper

@class Logger
@constructor
Simple Logging Helper