forked from cowboy/javascript-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ba-debug.min.js
12 lines (12 loc) · 1.19 KB
/
ba-debug.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*
* JavaScript Debug - v0.4 - 6/22/2010
* http://benalman.com/projects/javascript-debug-console-log/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* With lots of help from Paul Irish!
* http://paulirish.com/
*/
window.debug=function(){function l(b){e&&(f||!c||!c.log)&&e.apply(a,b)}function m(a){return g>0?g>a:h.length+g<=a}var a=this,b=Array.prototype.slice,c=a.console,d={},e,f,g=9,h=["error","warn","info","debug","log"],i="assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace".split(" "),j=i.length,k=[];while(--j>=0)(function(a){d[a]=function(){g!==0&&c&&c[a]&&c[a].apply(c,arguments)}})(i[j]);j=h.length;while(--j>=0)(function(e,f){d[f]=function(){var d=b.call(arguments),g=[f].concat(d);k.push(g),l(g);if(!c||!m(e))return;c.firebug?c[f].apply(a,d):c[f]?c[f](d):c.log(d)}})(j,h[j]);return d.setLevel=function(a){g=typeof a=="number"?a:9},d.getLevel=function(){return g},d.setCallback=function(){var a=b.call(arguments),c=k.length,d=c;e=a.shift()||null,f=typeof a[0]=="boolean"?a.shift():!1,d-=typeof a[0]=="number"?a.shift():c;while(d<c)l(k[d++])},d}()