aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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