add DEBUG usage docs. Closes #41

This commit is contained in:
TJ Holowaychuk 2013-11-26 21:37:22 -08:00
parent 309f2ac00e
commit 81d027eca7

View file

@ -92,7 +92,7 @@ function logger(format){
.replace(':url', this.url); .replace(':url', this.url);
console.log(str); console.log(str);
yield next; yield next;
} }
} }
@ -103,8 +103,7 @@ app.use(logger(':method :url'));
### Named middleware ### Named middleware
Naming middleware is optional, however it's useful for debugging purposes to Naming middleware is optional, however it's useful for debugging purposes to assign a name.
assign a name.
```js ```js
function logger(format){ function logger(format){
@ -136,3 +135,20 @@ app.use(function *(){
}); });
``` ```
## Debugging Koa
Koa along with many of the libraries it's built with support the __DEBUG__ environment variable from [debug](https://github.com/visionmedia/debug) which provides simple conditional logging.
For example
to see all koa-specific debugging information just pass `DEBUG=koa*` and upon boot you'll see the list of middleware used, among other things.
```
$ DEBUG=koa* node --harmony examples/simple
koa:application use responseTime +0ms
koa:application use logger +4ms
koa:application use contentLength +0ms
koa:application use notfound +0ms
koa:application use response +0ms
koa:application listen +0ms
```