mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
3b1cc6e500
having the key in there means its easy to analyise the logs based on the route
30 lines
1,012 B
CoffeeScript
30 lines
1,012 B
CoffeeScript
settings = require("settings-sharelatex")
|
|
logger = require "logger-sharelatex"
|
|
os = require("os")
|
|
metrics = require("../Metrics")
|
|
|
|
module.exports.logger = (req, res, next) ->
|
|
startTime = new Date()
|
|
end = res.end
|
|
res.end = () ->
|
|
end.apply(this, arguments)
|
|
responseTime = new Date() - startTime
|
|
routePath = req.route.path.toString().replace(/\//g, '-').slice(1)
|
|
|
|
processName = if settings.internal.web.name? then "web-#{settings.internal.web.name}" else "web"
|
|
key = "#{os.hostname()}.#{processName}.#{routePath}".toLowerCase().trim()
|
|
logger.log
|
|
req:
|
|
url: req.originalUrl || req.url
|
|
method: req.method
|
|
key:key
|
|
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": responseTime
|
|
"http request"
|
|
next()
|
|
|