Rack::CommonLogger forwards every request to an app given, and logs a line in the Apache common log format to the logger, or rack.errors by default.
Common Log Format: httpd.apache.org/docs/1.3/logs.html#common lilith.local - - [07/Aug/2006 23:58:02] “GET / HTTP/1.1“ 500 -
%{%s - %s [%s] "%s %s%s %s" %d %s\n} %
(Not documented)
# File lib/rack/commonlogger.rb, line 44
44: def extract_content_length(headers)
45: value = headers['Content-Length'] or return '-'
46: value.to_s == '0' ? '-' : value
47: end
(Not documented)
# File lib/rack/commonlogger.rb, line 26
26: def log(env, status, header, began_at)
27: now = Time.now
28: length = extract_content_length(header)
29:
30: logger = @logger || env['rack.errors']
31: logger.write FORMAT % [
32: env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
33: env["REMOTE_USER"] || "-",
34: now.strftime("%d/%b/%Y %H:%M:%S"),
35: env["REQUEST_METHOD"],
36: env["PATH_INFO"],
37: env["QUERY_STRING"].empty? ? "" : "?"+env["QUERY_STRING"],
38: env["HTTP_VERSION"],
39: status.to_s[0..3],
40: length,
41: now - began_at ]
42: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.