aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-06-27 02:13:53 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-06-27 02:13:53 -0300
commit261a8e1c4bcd08a7946a8ff8b59ba1085e4aab1e (patch)
treed8ca629f0ad69bb2284e207f42304aead448c9e0 /activerecord
parent9f94f73743a48511154d2801c484d9ac195832be (diff)
parentf5d8dd6d8fc13bf931896f8435baf9779b3136ab (diff)
downloadrails-261a8e1c4bcd08a7946a8ff8b59ba1085e4aab1e.tar.gz
rails-261a8e1c4bcd08a7946a8ff8b59ba1085e4aab1e.tar.bz2
rails-261a8e1c4bcd08a7946a8ff8b59ba1085e4aab1e.zip
Merge pull request #20607 from cmtonkinson/update-console-colors
More granular console SQL coloration
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/log_subscriber.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb
index af816a278e..4d597a0ab1 100644
--- a/activerecord/lib/active_record/log_subscriber.rb
+++ b/activerecord/lib/active_record/log_subscriber.rb
@@ -47,18 +47,21 @@ module ActiveRecord
binds = " " + payload[:binds].map { |attr| render_bind(attr) }.inspect
end
- if odd?
- name = color(name, CYAN, true)
- sql = color(sql, nil, true)
- else
- name = color(name, MAGENTA, true)
- end
+ name = color(name, nil, true)
+ sql = color(sql, sql_color(sql), true)
debug " #{name} #{sql}#{binds}"
end
- def odd?
- @odd = !@odd
+ def sql_color(sql)
+ case sql
+ when /\s*\Ainsert/i then GREEN
+ when /\s*\Aselect/i then BLUE
+ when /\s*\Aupdate/i then YELLOW
+ when /\s*\Adelete/i then RED
+ when /transaction\s*\Z/i then CYAN
+ else MAGENTA
+ end
end
def logger