aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/log_subscriber.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2011-05-01 19:10:21 -0600
committerDavid Heinemeier Hansson <david@loudthinking.com>2011-05-01 19:10:21 -0600
commit31155eeb3ce00e5f830171d34b2037fb7a1104f0 (patch)
tree01e6f703593a16219e5a71c3cf5f95538435a1af /activerecord/lib/active_record/log_subscriber.rb
parent635abc7194a0847fee1592eff9fa2fe84bafc5bf (diff)
downloadrails-31155eeb3ce00e5f830171d34b2037fb7a1104f0.tar.gz
rails-31155eeb3ce00e5f830171d34b2037fb7a1104f0.tar.bz2
rails-31155eeb3ce00e5f830171d34b2037fb7a1104f0.zip
Make the identity map use the instrumentation infrastructure so we can style the messages nicely with colors (FIXME: Can someone look into why the test is not working?)
Diffstat (limited to 'activerecord/lib/active_record/log_subscriber.rb')
-rw-r--r--activerecord/lib/active_record/log_subscriber.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb
index d31e321440..3a015ee8c2 100644
--- a/activerecord/lib/active_record/log_subscriber.rb
+++ b/activerecord/lib/active_record/log_subscriber.rb
@@ -46,6 +46,15 @@ module ActiveRecord
debug " #{name} #{sql}#{binds}"
end
+ def identity(event)
+ return unless logger.debug?
+
+ name = color(event.payload[:name], odd? ? CYAN : MAGENTA, true)
+ line = odd? ? color(event.payload[:line], nil, true) : event.payload[:line]
+
+ debug " #{name} #{line}"
+ end
+
def odd?
@odd_or_even = !@odd_or_even
end