overleaf/services/web/app/coffee/infrastructure/Monitor/HTTP.coffee
2014-02-12 10:23:40 +00:00

21 lines
632 B
CoffeeScript

logger = require "logger-sharelatex"
module.exports.logger = (req, res, next) ->
startTime = new Date()
end = res.end
res.end = () ->
end.apply(this, arguments)
logger.log
req:
url: req.originalUrl || req.url
method: req.method
referrer: req.headers['referer'] || req.headers['referrer']
"remote-addr": req.ip || req.socket?.socket?.remoteAddress || req.socket?.remoteAddress
"user-agent": req.headers["user-agent"]
"content-length": req.headers["content-length"]
res:
"content-length": res._headers?["content-length"]
"response-time": new Date() - startTime
"http request"
next()