aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-17 01:23:41 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-17 01:23:41 +0000
commitc00bf5f0c62f72f84629c6873791a591c02ae62c (patch)
tree1425ac9ed77fbc75a6ecf86e2b27b2838d28f2ec
parent2d9e59b2b6dec7d6e98bd594cbd5295a4b6689ed (diff)
downloadrails-c00bf5f0c62f72f84629c6873791a591c02ae62c.tar.gz
rails-c00bf5f0c62f72f84629c6873791a591c02ae62c.tar.bz2
rails-c00bf5f0c62f72f84629c6873791a591c02ae62c.zip
Fixed the verbosity of using the AR store
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@639 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_controller/session/active_record_store.rb8
-rwxr-xr-xactiverecord/lib/active_record/base.rb11
2 files changed, 14 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/session/active_record_store.rb b/actionpack/lib/action_controller/session/active_record_store.rb
index 27ef869132..9e0db037d0 100644
--- a/actionpack/lib/action_controller/session/active_record_store.rb
+++ b/actionpack/lib/action_controller/session/active_record_store.rb
@@ -29,8 +29,10 @@ class CGI
#
# This session's ActiveRecord database row will be created if it does not exist, or opened if it does.
def initialize(session, option=nil)
- @session = Session.find_by_sessid(session.session_id) || Session.new("sessid" => session.session_id, "data" => {})
- @data = @session.data
+ ActiveRecord::Base.silence do
+ @session = Session.find_by_sessid(session.session_id) || Session.new("sessid" => session.session_id, "data" => {})
+ @data = @session.data
+ end
end
# Update and close the session's ActiveRecord object.
@@ -56,7 +58,7 @@ class CGI
# Save session state in the session's ActiveRecord object.
def update
return unless @session
- ActiveRecord::Base.benchmark("Saving session") { @session.update_attribute "data", @data }
+ ActiveRecord::Base.silence { @session.update_attribute "data", @data }
end
end #ActiveRecordStore
end #Session
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 656258e49b..a79d75bba3 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -669,10 +669,17 @@ module ActiveRecord #:nodoc:
# end
def benchmark(title)
result = nil
+ bm = Benchmark.measure { result = silence { yield } }
+ logger.info "#{title} (#{sprintf("%f", bm.real)})"
+ return result
+ end
+
+ # Silences the logger for the duration of the block.
+ def silence
+ result = nil
logger.level = Logger::ERROR
- bm = Benchmark.measure { result = yield }
+ result = yield
logger.level = Logger::DEBUG
- logger.info "#{title} (#{sprintf("%f", bm.real)})"
return result
end