Permalink
Browse files

Don't use localStorage, require a `debug.enable` function instead.

  • Loading branch information...
1 parent ecf3e06 commit 81ed7be977a098ff7e3a5f771f225d00c2ab1dc8 @TooTallNate TooTallNate committed Feb 1, 2012
Showing with 10 additions and 17 deletions.
  1. +6 −15 debug.js
  2. +4 −2 example/browser.html
View
@@ -6,17 +6,6 @@
*/
/**
- * Enabled debuggers.
- */
-
-var names = (localStorage.debug || '')
- .split(/[\s,]+/)
- .map(function(name){
- name = name.replace('*', '.*?');
- return new RegExp('^' + name + '$');
- });
-
-/**
* Previous debug() call.
*/
@@ -31,11 +20,13 @@ var prev = {};
*/
function debug(name) {
- var match = names.some(function(re){
- return re.test(name);
- });
+ if (!debug.enable) {
+ throw new Error('You must set a function for `debug.enable`');
+ }
+
+ var enabled = debug.enable(name);
- if (!match) return function(){};
+ if (!enabled) return function(){};
function plain(fmt) {
var curr = new Date;
View
@@ -3,10 +3,12 @@
<title>debug()</title>
<script src="../debug.js"></script>
<script>
-
+ debug.enable = function(name) {
+ return true;
+ }
</script>
</head>
<body>
</body>
-</html>
+</html>

0 comments on commit 81ed7be

Please sign in to comment.