module Scrivito class LogSubscriber < ActiveSupport::LogSubscriber def self.runtime=(value) Thread.current["scrivito_cms_load_runtime"] = value end def self.runtime Thread.current["scrivito_cms_load_runtime"] ||= 0 end def self.reset_runtime rt, self.runtime = runtime, 0 rt end def cms_load(event) self.class.runtime += event.duration return unless logger.debug? name = '%s (%.1fms)' % [event.payload[:name], event.duration] debug " #{name} #{event.payload[:index]} #{event.payload[:keys].inspect}" end def backend_request(event) self.class.runtime += event.duration return unless logger.debug? duration = '(%.1fms)' % [event.duration] param = event.payload[:params] param_text = " #{param}" if param verb_text = event.payload[:verb].upcase path_text = event.payload[:path] debug " Scrivito #{verb_text} #{path_text}#{param_text} #{duration}" end def logger Rails.logger end end end