0.0.2 • Published 10 years ago

accesslog v0.0.2

Weekly downloads
54
License
-
Repository
github
Last release
10 years ago

accesslog

Simple common/combined access log middleware

Usage

$ npm install accesslog

accesslog([options])

Creates a middleware request handler which logs requests to a file or stream in 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 style. Defaults to "combined" format.

Example

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

0.0.2

10 years ago

0.0.1

12 years ago

0.0.0

12 years ago