'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;
}, {});
}; |