[Pkg-javascript-commits] [node-debug] 11/14: Imported Upstream version 0.8.1

Leo Iannacone l3on-guest at moszumanska.debian.org
Wed Apr 23 16:25:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

l3on-guest pushed a commit to branch master
in repository node-debug.

commit 9490b26fd9e6bf97d0d982aea484690ee258c576
Author: Leo Iannacone <leo.iannacone at gmail.com>
Date:   Wed Apr 23 18:11:47 2014 +0200

    Imported Upstream version 0.8.1
---
 .gitignore           |  4 +++
 .npmignore           |  1 +
 History.md           | 59 ++++++++++++++++++++++++++++++++++++-----
 Makefile             |  6 ++---
 Readme.md            | 34 +++++++-----------------
 component.json       | 10 +++++++
 debug.js             | 27 ++++++++++++++-----
 example/browser.html |  5 ++--
 example/worker.js    |  6 ++++-
 index.js             |  2 --
 lib/debug.js         | 75 ++++++++++++++++++++++++++++++----------------------
 package.json         | 17 +++++++++---
 12 files changed, 164 insertions(+), 82 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c78f347
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.DS_Store
+node_modules
+*.sock
+build
diff --git a/.npmignore b/.npmignore
index f1250e5..fc10b6f 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,4 +1,5 @@
 support
 test
 examples
+example
 *.sock
diff --git a/History.md b/History.md
index f3c1a98..0d9a49a 100644
--- a/History.md
+++ b/History.md
@@ -1,11 +1,56 @@
 
-0.6.0 / 2012-03-16 
+0.8.1 / 2014-04-14
+==================
+
+ * package: re-add the "component" section
+
+0.8.0 / 2014-03-30
+==================
+
+ * add `enable()` method for nodejs. Closes #27
+ * change from stderr to stdout
+ * remove unnecessary index.js file
+
+0.7.4 / 2013-11-13
+==================
+
+ * remove "browserify" key from package.json (fixes something in browserify)
+
+0.7.3 / 2013-10-30
+==================
+
+ * fix: catch localStorage security error when cookies are blocked (Chrome)
+ * add debug(err) support. Closes #46
+ * add .browser prop to package.json. Closes #42
+
+0.7.2 / 2013-02-06
+==================
+
+  * fix package.json
+  * fix: Mobile Safari (private mode) is broken with debug
+  * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
+
+0.7.1 / 2013-02-05
+==================
+
+  * add repository URL to package.json
+  * add DEBUG_COLORED to force colored output
+  * add browserify support
+  * fix component. Closes #24
+
+0.7.0 / 2012-05-04
+==================
+
+  * Added .component to package.json
+  * Added debug.component.js build
+
+0.6.0 / 2012-03-16
 ==================
 
   * Added support for "-" prefix in DEBUG [Vinay Pulim]
-  * Added `.enabled` flag to the node version [TooTallNate] 
+  * Added `.enabled` flag to the node version [TooTallNate]
 
-0.5.0 / 2012-02-02 
+0.5.0 / 2012-02-02
 ==================
 
   * Added: humanize diffs. Closes #8
@@ -13,24 +58,24 @@
   * Removed padding. Closes #10
   * Fixed: persist client-side variant again. Closes #9
 
-0.4.0 / 2012-02-01 
+0.4.0 / 2012-02-01
 ==================
 
   * Added browser variant support for older browsers [TooTallNate]
   * Added `debug.enable('project:*')` to browser variant [TooTallNate]
   * Added padding to diff (moved it to the right)
 
-0.3.0 / 2012-01-26 
+0.3.0 / 2012-01-26
 ==================
 
   * Added millisecond diff when isatty, otherwise UTC string
 
-0.2.0 / 2012-01-22 
+0.2.0 / 2012-01-22
 ==================
 
   * Added wildcard support
 
-0.1.0 / 2011-12-02 
+0.1.0 / 2011-12-02
 ==================
 
   * Added: remove colors unless stderr isatty [TooTallNate]
diff --git a/Makefile b/Makefile
index 36a3ed7..9c37f69 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,3 @@
 
-test:
-	@echo "populate me"
-
-.PHONY: test
\ No newline at end of file
+build: debug.js
+	component build
diff --git a/Readme.md b/Readme.md
index 419fcdf..8981f8a 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,7 +1,6 @@
-
 # debug
 
-  tiny node.js debugging utility.
+  tiny node.js debugging utility modelled after node core's debugging technique.
 
 ## Installation
 
@@ -9,25 +8,10 @@
 $ npm install debug
 ```
 
-## Example
+## Usage
 
-  This module is modelled after node core's debugging technique, allowing you to enable one or more topic-specific debugging functions, for example core does the following within many modules:
+ With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
 
-```js
-var debug;
-if (process.env.NODE_DEBUG && /cluster/.test(process.env.NODE_DEBUG)) {
-  debug = function(x) {
-    var prefix = process.pid + ',' +
-        (process.env.NODE_WORKER_ID ? 'Worker' : 'Master');
-    console.error(prefix, x);
-  };
-} else {
-  debug = function() { };
-}
-```
-
- This concept is extremely simple but it works well. With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
- 
 Example _app.js_:
 
 ```js
@@ -74,22 +58,22 @@ setInterval(function(){
   ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)
 
   When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
-  
+
   ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)
 
 ## Conventions
 
- If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". 
+ If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
 
 ## Wildcards
 
-  The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
+  The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
 
   You can also exclude specific debuggers by prefixing them with a "-" character.  For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:".
 
 ## Browser support
 
- Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. 
+ Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`.
 
 ```js
 a = debug('worker:a');
@@ -104,7 +88,7 @@ setInterval(function(){
 }, 1200);
 ```
 
-## License 
+## License
 
 (The MIT License)
 
@@ -127,4 +111,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..cb76981
--- /dev/null
+++ b/component.json
@@ -0,0 +1,10 @@
+{
+  "name": "debug",
+  "repo": "visionmedia/debug",
+  "description": "small debugging utility",
+  "version": "0.7.4",
+  "keywords": ["debug", "log", "debugger"],
+  "main": "debug.js",
+  "scripts": ["debug.js"],
+  "dependencies": {}
+}
diff --git a/debug.js b/debug.js
index b2f0798..509dc0d 100644
--- a/debug.js
+++ b/debug.js
@@ -1,10 +1,10 @@
 
-/*!
- * debug
- * Copyright(c) 2012 TJ Holowaychuk <tj at vision-media.ca>
- * MIT Licensed
+/**
+ * Expose `debug()` as the module.
  */
 
+module.exports = debug;
+
 /**
  * Create a debugger with the given `name`.
  *
@@ -17,6 +17,8 @@ function debug(name) {
   if (!debug.enabled(name)) return function(){};
 
   return function(fmt){
+    fmt = coerce(fmt);
+
     var curr = new Date;
     var ms = curr - (debug[name] || curr);
     debug[name] = curr;
@@ -50,7 +52,9 @@ debug.skips = [];
  */
 
 debug.enable = function(name) {
-  localStorage.debug = name;
+  try {
+    localStorage.debug = name;
+  } catch(e){}
 
   var split = (name || '').split(/[\s,]+/)
     , len = split.length;
@@ -117,6 +121,17 @@ debug.enabled = function(name) {
   return false;
 };
 
+/**
+ * Coerce `val`.
+ */
+
+function coerce(val) {
+  if (val instanceof Error) return val.stack || val.message;
+  return val;
+}
+
 // persist
 
-if (window.localStorage) debug.enable(localStorage.debug);
\ No newline at end of file
+try {
+  if (window.localStorage) debug.enable(localStorage.debug);
+} catch(e){}
diff --git a/example/browser.html b/example/browser.html
index 7510eee..9baa91f 100644
--- a/example/browser.html
+++ b/example/browser.html
@@ -1,10 +1,11 @@
 <html>
   <head>
     <title>debug()</title>
-    <script src="../debug.js"></script>
+    <script src="../build/build.js"></script>
     <script>
       // type debug.enable('*') in
       // the console and refresh :)
+      var debug = require('debug');
 
       a = debug('worker:a');
       b = debug('worker:b');
@@ -19,6 +20,6 @@
     </script>
   </head>
   <body>
-    
+
   </body>
 </html>
diff --git a/example/worker.js b/example/worker.js
index 7f6d288..22225f6 100644
--- a/example/worker.js
+++ b/example/worker.js
@@ -19,4 +19,8 @@ function workb() {
   setTimeout(workb, Math.random() * 2000);
 }
 
-workb();
\ No newline at end of file
+workb();
+
+setTimeout(function(){
+  b(new Error('fail'));
+}, 5000);
diff --git a/index.js b/index.js
deleted file mode 100644
index ee54454..0000000
--- a/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-
-module.exports = require('./lib/debug');
\ No newline at end of file
diff --git a/lib/debug.js b/lib/debug.js
index 984dfb5..e7422e6 100644
--- a/lib/debug.js
+++ b/lib/debug.js
@@ -1,10 +1,3 @@
-
-/*!
- * debug
- * Copyright(c) 2012 TJ Holowaychuk <tj at vision-media.ca>
- * MIT Licensed
- */
-
 /**
  * Module dependencies.
  */
@@ -18,29 +11,12 @@ var tty = require('tty');
 module.exports = debug;
 
 /**
- * Library version.
- */
-
-exports.version = '0.6.0';
-
-/**
  * Enabled debuggers.
  */
 
 var names = []
   , skips = [];
 
-(process.env.DEBUG || '')
-  .split(/[\s,]+/)
-  .forEach(function(name){
-    name = name.replace('*', '.*?');
-    if (name[0] === '-') {
-      skips.push(new RegExp('^' + name.substr(1) + '$'));
-    } else {
-      names.push(new RegExp('^' + name + '$'));
-    }
-  });
-
 /**
  * Colors.
  */
@@ -63,7 +39,7 @@ var prevColor = 0;
  * Is stdout a TTY? Colored output is disabled when `true`.
  */
 
-var isatty = tty.isatty(2);
+var isatty = tty.isatty(1);
 
 /**
  * Select a color.
@@ -121,27 +97,62 @@ function debug(name) {
   var c = color();
 
   function colored(fmt) {
+    fmt = coerce(fmt);
+
     var curr = new Date;
     var ms = curr - (prev[name] || curr);
     prev[name] = curr;
 
-    fmt = '  \033[9' + c + 'm' + name + ' '
-      + '\033[3' + c + 'm\033[90m'
-      + fmt + '\033[3' + c + 'm'
-      + ' +' + humanize(ms) + '\033[0m';
+    fmt = '  \u001b[9' + c + 'm' + name + ' '
+      + '\u001b[3' + c + 'm\u001b[90m'
+      + fmt + '\u001b[3' + c + 'm'
+      + ' +' + humanize(ms) + '\u001b[0m';
 
-    console.error.apply(this, arguments);
+    console.log.apply(this, arguments);
   }
 
   function plain(fmt) {
+    fmt = coerce(fmt);
+
     fmt = new Date().toUTCString()
       + ' ' + name + ' ' + fmt;
-    console.error.apply(this, arguments);
+    console.log.apply(this, arguments);
   }
 
   colored.enabled = plain.enabled = true;
 
-  return isatty
+  return isatty || process.env.DEBUG_COLORS
     ? colored
     : plain;
 }
+
+/**
+ * Coerce `val`.
+ */
+
+function coerce(val) {
+  if (val instanceof Error) return val.stack || val.message;
+  return val;
+}
+
+/**
+ * Enable specified `namespaces` for debugging.
+ */
+
+debug.enable = function(namespaces) {
+  namespaces.split(/[\s,]+/)
+  .forEach(function(name){
+    name = name.replace('*', '.*?');
+    if (name[0] == '-') {
+      skips.push(new RegExp('^' + name.substr(1) + '$'));
+    } else {
+      names.push(new RegExp('^' + name + '$'));
+    }
+  });
+};
+
+/**
+ * Enable namespaces listed in `process.env.DEBUG` initially.
+ */
+
+debug.enable(process.env.DEBUG || '');
diff --git a/package.json b/package.json
index 0555dfa..7051d22 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,22 @@
 {
     "name": "debug"
-  , "version": "0.6.0"
+  , "version": "0.8.1"
+  , "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" }
   , "description": "small debugging utility"
   , "keywords": ["debug", "log", "debugger"]
   , "author": "TJ Holowaychuk <tj at vision-media.ca>"
   , "dependencies": {}
   , "devDependencies": { "mocha": "*" }
-  , "main": "index"
+  , "main": "lib/debug.js"
+  , "browser": "./debug.js"
   , "engines": { "node": "*" }
-}
\ No newline at end of file
+  , "files": [
+      "lib/debug.js",
+      "debug.js"
+    ]
+  , "component": {
+      "scripts": {
+        "debug/index.js": "debug.js"
+      }
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-debug.git



More information about the Pkg-javascript-commits mailing list