log.js 450 B

123456789101112131415161718
  1. 'use strict';
  2. var logObject = {};
  3. ['log', 'debug', 'warn'].forEach(function (level) {
  4. var levelExists;
  5. try {
  6. levelExists = global.console && global.console[level] && global.console[level].apply;
  7. } catch(e) {
  8. // do nothing
  9. }
  10. logObject[level] = levelExists ? function () {
  11. return global.console[level].apply(global.console, arguments);
  12. } : (level === 'log' ? function () {} : logObject.log);
  13. });
  14. module.exports = logObject;