-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Carlos Rodriguez
committed
Jul 22, 2012
1 parent
18c7f8c
commit e4f4a4c
Showing
1 changed file
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,50 @@ | ||
node-accesslog | ||
============== | ||
accesslog | ||
--------- | ||
|
||
Simple common/combined access log middleware | ||
Simple common/combined access log middleware | ||
|
||
Usage | ||
===== | ||
|
||
```bash | ||
$ npm install accesslog | ||
``` | ||
|
||
`accesslog([options])` | ||
|
||
Creates a middleware request handler which logs requests to a file or stream in | ||
[common log format](http://en.wikipedia.org/wiki/Common_Log_Format). | ||
|
||
- `options` | ||
|
||
- `stream`: Stream to log to. Defaults to `process.stdout`. | ||
- `path`: Write log to a file at this path. | ||
- `format`: Format of log, in | ||
[Apache](http://httpd.apache.org/docs/1.3/logs.html#combined) style. Defaults | ||
to "combined" format. | ||
|
||
Example | ||
======= | ||
|
||
```javascript | ||
var accesslog = require('accesslog')() | ||
, http = require('http') | ||
, port = 3000 | ||
; | ||
|
||
http.createServer(function(req, res) { | ||
accesslog(req, res, function() { | ||
var content = JSON.stringify({'hello': 'world'}); | ||
res.writeHead(200, {'Content-Type': 'application/json', 'Content-Length': content.length}); | ||
res.write(content); | ||
res.end(); | ||
}); | ||
}).listen(port, function() { | ||
console.log('test server listening on port ' + port); | ||
}); | ||
``` | ||
|
||
License | ||
======= | ||
|
||
MIT |