From 51140942f034c954c4cd641ea61b0010490fe8ba Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sat, 5 Jan 2013 14:46:16 -0500 Subject: [PATCH] clarify usage in readme --- Readme.md | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Readme.md b/Readme.md index 419fcdf5..15ee5019 100644 --- a/Readme.md +++ b/Readme.md @@ -1,7 +1,7 @@ # debug - tiny node.js debugging utility. + tiny node.js debugging utility modelled after node core's debugging technique. ## Installation @@ -9,24 +9,9 @@ $ 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: - -```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. + 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_: