Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding access-log dependency

  • Loading branch information...
commit 362c9d6e6a55c5b07923604601eddc251e96b316 1 parent 1a61e41
@bahamas10 authored
Showing with 3 additions and 16 deletions.
  1. +0 −2  decorate.js
  2. +1 −0  package.json
  3. +2 −14 server.js
View
2  decorate.js
@@ -8,8 +8,6 @@ var url = require('url');
module.exports = decorate;
function decorate(req, res) {
- req.received_date = new Date();
-
req.url_parsed = url.parse(req.url, true);
req.url_parsed.pathname = path.normalize(req.url_parsed.pathname);
View
1  package.json
@@ -16,6 +16,7 @@
"open": "~ 0.0.2",
"routes": "~ 0.1.0",
"log-timestamp": "~ 0.0.1",
+ "access-log": "~ 0.1.0",
"rimraf": "~2.0.2",
"mkdirp": "~0.3.3",
"async": "~0.1.22",
View
16 server.js
@@ -3,6 +3,7 @@ var fs = require('fs');
var path = require('path');
var util = require('util');
+var accesslog = require('access-log');
var open = require('open');
var request = require('request');
var async = require('async');
@@ -82,20 +83,7 @@ module.exports = function(_conf) {
// Request received
function on_request(req, res) {
decorate(req, res);
-
- // log when a response is a set (to get code and everything)
- var res_end = res.end;
- res.end = function() {
- // call the original
- res_end.apply(res, arguments);
-
- // response done, now do the logging
- var delta = new Date() - req.received_date;
- weblog('%s %s %s %s (%dms)',
- req.connection.remoteAddress, req.method,
- res.statusCode, req.url, delta);
-
- };
+ accesslog(req, res, weblog);
// Extract the URL
var route = router.match(req.url_parsed.pathname);
Please sign in to comment.
Something went wrong with that request. Please try again.