Ok this should actually fix it

This commit is contained in:
calzoneman 2014-09-11 19:00:27 -05:00
parent 2ea9dbcb75
commit 731ab3f9a5
1 changed files with 5 additions and 2 deletions

View File

@ -14,6 +14,9 @@ var cookieParser = require("cookie-parser");
var static = require("serve-static");
var morgan = require("morgan");
const LOG_FORMAT = ':real-address - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"';
morgan.token('real-address', function (req) { return req._ip; });
/**
* Extracts an IP address from a request. Uses X-Forwarded-For if the IP is localhost
*/
@ -202,12 +205,12 @@ module.exports = {
*/
init: function (app) {
app.use(function (req, res, next) {
req.ip = ipForRequest(req);
req._ip = ipForRequest(req);
next();
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(morgan("combined", {
app.use(morgan(LOG_FORMAT, {
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
"http.log"), {
flags: "a",