You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
450 B

4 years ago
  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;