aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/log_subscriber.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-02-10 13:34:33 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-10 13:34:33 -0800
commit2f49cd91b7fdf18a559216fa725d039a5cd78ff1 (patch)
tree7dfa3f01b96319d653801a1687ffd495f7b1ca4b /activerecord/lib/active_record/log_subscriber.rb
parent028016ede382de80b9e91a7e13cd5372c2afd4bd (diff)
downloadrails-2f49cd91b7fdf18a559216fa725d039a5cd78ff1.tar.gz
rails-2f49cd91b7fdf18a559216fa725d039a5cd78ff1.tar.bz2
rails-2f49cd91b7fdf18a559216fa725d039a5cd78ff1.zip
bind parameters are logged to debug log
Diffstat (limited to 'activerecord/lib/active_record/log_subscriber.rb')
-rw-r--r--activerecord/lib/active_record/log_subscriber.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb
index c7ae12977a..a08b3562d0 100644
--- a/activerecord/lib/active_record/log_subscriber.rb
+++ b/activerecord/lib/active_record/log_subscriber.rb
@@ -22,8 +22,16 @@ module ActiveRecord
self.class.runtime += event.duration
return unless logger.debug?
- name = '%s (%.1fms)' % [event.payload[:name], event.duration]
- sql = event.payload[:sql].squeeze(' ')
+ payload = event.payload
+ name = '%s (%.1fms)' % [payload[:name], event.duration]
+ sql = payload[:sql].squeeze(' ')
+ binds = nil
+
+ unless (payload[:binds] || []).empty?
+ binds = " {" + payload[:binds].map { |col,v|
+ "#{col.name.inspect} => #{v.inspect}"
+ }.join(", ") + "}"
+ end
if odd?
name = color(name, CYAN, true)
@@ -32,7 +40,7 @@ module ActiveRecord
name = color(name, MAGENTA, true)
end
- debug " #{name} #{sql}"
+ debug " #{name} #{sql}#{binds}"
end
def odd?
@@ -45,4 +53,4 @@ module ActiveRecord
end
end
-ActiveRecord::LogSubscriber.attach_to :active_record \ No newline at end of file
+ActiveRecord::LogSubscriber.attach_to :active_record