diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
commit | b04230e3bbf912d60601e9e7b797c4cd43581d51 (patch) | |
tree | 97a2f784a2ec2bfae4f960af56a9280dad6f7774 /actionpack/lib/action_controller/railties | |
parent | 867829b187969607aa12f2b0457f25da9c204db0 (diff) | |
parent | 6e3bee6cf1f0d2684152292db0a8b757249824fd (diff) | |
download | rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.gz rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.bz2 rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.zip |
Merge remote branch 'mainstream/master'
Conflicts:
actionpack/lib/action_controller/metal/flash.rb
Diffstat (limited to 'actionpack/lib/action_controller/railties')
-rw-r--r-- | actionpack/lib/action_controller/railties/subscriber.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/railties/subscriber.rb b/actionpack/lib/action_controller/railties/subscriber.rb new file mode 100644 index 0000000000..a9f5d16c58 --- /dev/null +++ b/actionpack/lib/action_controller/railties/subscriber.rb @@ -0,0 +1,60 @@ +module ActionController + module Railties + class Subscriber < Rails::Subscriber + def process_action(event) + payload = event.payload + + info "\nProcessed #{payload[:controller]}##{payload[:action]} " \ + "to #{payload[:formats].join(', ')} (for #{payload[:remote_ip]} at #{event.time.to_s(:db)}) " \ + "[#{payload[:method].to_s.upcase}]" + + info " Parameters: #{payload[:params].inspect}" unless payload[:params].blank? + + additions = ActionController::Base.log_process_action(payload) + + message = "Completed in %.0fms" % event.duration + message << " (#{additions.join(" | ")})" unless additions.blank? + message << " | #{payload[:status]} [#{payload[:request_uri]}]\n\n" + + info(message) + end + + def send_file(event) + message = if event.payload[:x_sendfile] + header = ActionController::Streaming::X_SENDFILE_HEADER + "Sent #{header} header %s" + elsif event.payload[:stream] + "Streamed file %s" + else + "Sent file %s" + end + + message << " (%.1fms)" + info(message % [event.payload[:path], event.duration]) + end + + def redirect_to(event) + info "Redirected to #{event.payload[:location]}" + end + + def send_data(event) + info("Sent data %s (%.1fms)" % [event.payload[:filename], event.duration]) + end + + %w(write_fragment read_fragment exist_fragment? + expire_fragment expire_page write_page).each do |method| + class_eval <<-METHOD, __FILE__, __LINE__ + 1 + def #{method}(event) + key_or_path = event.payload[:key] || event.payload[:path] + human_name = #{method.to_s.humanize.inspect} + info("\#{human_name} \#{key_or_path} (%.1fms)" % event.duration) + end + METHOD + end + + def logger + ActionController::Base.logger + end + end + end +end
\ No newline at end of file |