lib/racknga/middleware/log.rb in racknga-0.9.2 vs lib/racknga/middleware/log.rb in racknga-0.9.3
- old
+ new
@@ -68,28 +68,33 @@
end
private
def log(start_time, end_time, request, status, headers, body)
request_time = end_time - start_time
+ runtime = headers["X-Runtime"]
+ runtime_in_float = nil
+ runtime_in_float = runtime.to_f if runtime
length = headers["Content-Length"] || "-"
length = "-" if length == "0"
- format = "%s - %s [%s] \"%s %s %s\" %s %s \"%s\" \"%s\" %0.8f"
+ format = "%s - %s [%s] \"%s %s %s\" %s %s \"%s\" \"%s\" %s %0.8f"
message = format % [request.ip || "-",
request.env["REMOTE_USER"] || "-",
end_time.dup.utc.strftime("%d/%b/%Y:%H:%M:%S %z"),
request.request_method,
request.fullpath,
request.env["SERVER_PROTOCOL"] || "-",
status.to_s[0..3],
length,
request.env["HTTP_REFERER"] || "-",
request.user_agent || "-",
+ runtime || "-",
request_time]
@logger.log("access",
request.fullpath,
:message => message,
:user_agent => request.user_agent,
- :runtime => request_time)
+ :runtime => runtime_in_float,
+ :request_time => request_time)
end
# @private
class Logger
def initialize(database)