* Create a debugger with the given `name`. * * @param {String} name * @return {Type} * @api public
(name)
| 736 | */ |
| 737 | |
| 738 | function debug(name) { |
| 739 | if (!debug.enabled(name)) return function(){}; |
| 740 | |
| 741 | return function(fmt){ |
| 742 | fmt = coerce(fmt); |
| 743 | |
| 744 | var curr = new Date; |
| 745 | var ms = curr - (debug[name] || curr); |
| 746 | debug[name] = curr; |
| 747 | |
| 748 | fmt = name |
| 749 | + ' ' |
| 750 | + fmt |
| 751 | + ' +' + debug.humanize(ms); |
| 752 | |
| 753 | // This hackery is required for IE8 |
| 754 | // where `console.log` doesn't have 'apply' |
| 755 | window.console |
| 756 | && console.log |
| 757 | && Function.prototype.apply.call(console.log, console, arguments); |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * The currently active debug mode names. |
no test coverage detected