Sha256: df1b92e00551de7cc3d47b4541e23ca929dc944fcfad5c177b4f14e612095b6f
Contents?: true
Size: 979 Bytes
Versions: 23
Compression:
Stored size: 979 Bytes
Contents
module MontageRails class LogSubscriber < ActiveSupport::LogSubscriber def self.runtime=(value) Thread.current["montage_rails_reql_runtime"] = value end def self.runtime Thread.current["montage_rails_reql_runtime"] ||= 0 end def self.reset_runtime rt, self.runtime = runtime, 0 rt end def initialize super @odd_or_even = false end def reql(event) self.class.runtime += event.duration return unless logger.debug? name = '%s (%.1fms)' % [event.payload[:name], event.duration] reql = event.payload[:reql] if odd? name = color(name, CYAN, true) reql = color(reql, nil, true) else name = color(name, MAGENTA, true) end debug " #{name} #{reql}" end def odd? @odd_or_even = !@odd_or_even end def logger MontageRails::Base.logger end end end MontageRails::LogSubscriber.attach_to :montage_rails
Version data entries
23 entries across 23 versions & 1 rubygems