Class: ActiveProfiling::ActiveRecord::BacktraceLogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- ActiveProfiling::ActiveRecord::BacktraceLogSubscriber
- Defined in:
- lib/active-profiling/active_record/backtrace_log_subscriber.rb
Instance Method Summary collapse
Instance Method Details
#logger ⇒ Object
26 27 28 |
# File 'lib/active-profiling/active_record/backtrace_log_subscriber.rb', line 26 def logger ::ActiveRecord::Base.logger end |
#sql(event) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active-profiling/active_record/backtrace_log_subscriber.rb', line 4 def sql(event) return unless config.enabled && config.log_level && logger && logger.send("#{config.log_level}?") payload = event.payload return if 'SCHEMA' == payload[:name] backtrace = event.send(:caller).collect { |line| if line_match(line) " #{line}" end }.compact unless backtrace.empty? name = color(payload[:name], YELLOW, true) logger.send(config.log_level, " #{name}\n#{backtrace.join("\n")}") end end |