class Rack::CommonLogger

def log(env, status, header, began_at)

Log the request to the configured logger.
def log(env, status, header, began_at)
  length = extract_content_length(header)
  msg = FORMAT % [
    env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
    env["REMOTE_USER"] || "-",
    Time.now.strftime("%d/%b/%Y:%H:%M:%S %z"),
    env[REQUEST_METHOD],
    env[SCRIPT_NAME],
    env[PATH_INFO],
    env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}",
    env[SERVER_PROTOCOL],
    status.to_s[0..3],
    length,
    Utils.clock_time - began_at ]
  msg.gsub!(/[^[:print:]\n]/) { |c| "\\x#{c.ord}" }
  logger = @logger || env[RACK_ERRORS]
  # Standard library logger doesn't support write but it supports << which actually
  # calls to write on the log device without formatting
  if logger.respond_to?(:write)
    logger.write(msg)
  else
    logger << msg
  end
end