console.js 744 B

12345678910111213141516171819
  1. /**
  2. * An idiot proof logger to be used as default. We've wrapped it in a try/catch
  3. * statement to ensure the environments without the `console` API do not crash
  4. * as well as an additional fix for ancient browsers like IE8 where the
  5. * `console.log` API doesn't have an `apply`, so we need to use the Function's
  6. * apply functionality to apply the arguments.
  7. *
  8. * @param {Object} meta Options of the logger.
  9. * @param {Array} messages The actuall message that needs to be logged.
  10. * @public
  11. */
  12. module.exports = function (meta, messages) {
  13. //
  14. // So yea. IE8 doesn't have an apply so we need a work around to puke the
  15. // arguments in place.
  16. //
  17. try { Function.prototype.apply.call(console.log, console, messages); }
  18. catch (e) {}
  19. }