debug.js 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var config = require('../config')
  2. /**
  3. * Enable debug utilities. The enableDebug() function and
  4. * all _.log() & _.warn() calls will be dropped in the
  5. * minified production build.
  6. */
  7. enableDebug()
  8. function enableDebug () {
  9. var hasConsole = typeof console !== 'undefined'
  10. /**
  11. * Log a message.
  12. *
  13. * @param {String} msg
  14. */
  15. exports.log = function (msg) {
  16. if (hasConsole && config.debug) {
  17. console.log('[Vue info]: ' + msg)
  18. }
  19. }
  20. /**
  21. * We've got a problem here.
  22. *
  23. * @param {String} msg
  24. */
  25. exports.warn = function (msg) {
  26. if (hasConsole && !config.silent) {
  27. console.warn('[Vue warn]: ' + msg)
  28. if (config.debug && console.trace) {
  29. console.trace()
  30. }
  31. }
  32. }
  33. /**
  34. * Assert asset exists
  35. */
  36. exports.assertAsset = function (val, type, id) {
  37. if (!val) {
  38. exports.warn('Failed to resolve ' + type + ': ' + id)
  39. }
  40. }
  41. }