diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-14 17:25:10 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-14 17:25:10 -0700 |
commit | da65320433088548bc4cff33758e5acd71fd137a (patch) | |
tree | 97a5b945c5fece6da744383fda42072b3296988e /actionpack/lib/action_controller/abstract/logger.rb | |
parent | 8fac2c88cae0f2fd42fad3c2c2c6c860df14d629 (diff) | |
download | rails-da65320433088548bc4cff33758e5acd71fd137a.tar.gz rails-da65320433088548bc4cff33758e5acd71fd137a.tar.bz2 rails-da65320433088548bc4cff33758e5acd71fd137a.zip |
Got new base to pass controller/base_test.rb, implemented method_missing action semantics in compatibility mode, and fixed a few action_missing bugs.
Diffstat (limited to 'actionpack/lib/action_controller/abstract/logger.rb')
-rw-r--r-- | actionpack/lib/action_controller/abstract/logger.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb index 5fb78f1755..d0603a4ad7 100644 --- a/actionpack/lib/action_controller/abstract/logger.rb +++ b/actionpack/lib/action_controller/abstract/logger.rb @@ -2,8 +2,41 @@ module AbstractController module Logger extend ActiveSupport::DependencyModule + class DelayedLog + def initialize(&blk) + @blk = blk + end + + def to_s + @blk.call + end + alias to_str to_s + end + included do cattr_accessor :logger end + + def process(action) + ret = super + + if logger + log = DelayedLog.new do + "\n\nProcessing #{self.class.name}\##{action_name} " \ + "to #{request.formats} " \ + "(for #{request_origin}) [#{request.method.to_s.upcase}]" + end + + logger.info(log) + end + + ret + end + + def request_origin + # this *needs* to be cached! + # otherwise you'd get different results if calling it more than once + @request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}" + end end end
\ No newline at end of file |