From e4f4a4cd138f434df9fd60ca577e57259929ad2b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sat, 21 Jul 2012 17:22:31 -0700 Subject: [PATCH] Fill out readme --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0fbe701..781ff27 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,50 @@ -node-accesslog -============== +accesslog +--------- -Simple common/combined access log middleware \ No newline at end of file +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 \ No newline at end of file