Skip to content

Commit 87e7399

Browse files
committed
readme++
1 parent 8b5c438 commit 87e7399

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ npm install debug
1919

2020
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
2121

22-
Example _app.js_:
22+
Example [_app.js_](./examples/node/app.js):
2323

2424
```js
2525
var debug = require('debug')('http')
@@ -42,14 +42,25 @@ http.createServer(function(req, res){
4242
require('./worker');
4343
```
4444

45-
Example _worker.js_:
45+
Example [_worker.js_](./examples/node/worker.js):
4646

4747
```js
48-
var debug = require('debug')('worker');
48+
var a = require('debug')('worker:a')
49+
, b = require('debug')('worker:b');
4950

50-
setInterval(function(){
51-
debug('doing some work');
52-
}, 1000);
51+
function work() {
52+
a('doing lots of uninteresting work');
53+
setTimeout(work, Math.random() * 1000);
54+
}
55+
56+
work();
57+
58+
function workb() {
59+
b('doing some work');
60+
setTimeout(workb, Math.random() * 2000);
61+
}
62+
63+
workb();
5364
```
5465

5566
The `DEBUG` environment variable is then used to enable these based on space or

0 commit comments

Comments
 (0)