Code coverage report for src/logger.js

Statements: 87.5% (7 / 8)      Branches: 75% (3 / 4)      Functions: 100% (2 / 2)      Lines: 87.5% (7 / 8)      Ignored: none     

All files » src/ » logger.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19      1     1   1 5 5       5   5    
'use strict';
 
// TODO(kanitw): chat with Vega team and possibly move this to vega-logging
module.exports = function(prefix) {
  // Borrowed some ideas from http://stackoverflow.com/a/15653260/866989
  // and https://github.com/patik/console.log-wrapper/blob/master/consolelog.js
  var METHODS = ['error', 'info', 'debug', 'warn', 'log'];
 
  return METHODS.reduce(function(logger, fn) {
    var cfn = console[fn] ? fn : 'log';
    Iif (console[cfn].bind === 'undefined') { // IE < 10
        logger[fn] = Function.prototype.bind.call(console[cfn], console, prefix);
    }
    else {
        logger[fn] = console[cfn].bind(console, prefix);
    }
    return logger;
  }, {});
};