We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9f94f73 + f5d8dd6 commit 261a8e1Copy full SHA for 261a8e1
activerecord/lib/active_record/log_subscriber.rb
@@ -47,18 +47,21 @@ def sql(event)
47
binds = " " + payload[:binds].map { |attr| render_bind(attr) }.inspect
48
end
49
50
- if odd?
51
- name = color(name, CYAN, true)
52
- sql = color(sql, nil, true)
53
- else
54
- name = color(name, MAGENTA, true)
55
- end
+ name = color(name, nil, true)
+ sql = color(sql, sql_color(sql), true)
56
57
debug " #{name} #{sql}#{binds}"
58
59
60
- def odd?
61
- @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
62
+ when /transaction\s*\Z/i then CYAN
63
+ else MAGENTA
64
+ end
65
66
67
def logger
0 commit comments