Sha256: b1f95511a81caad779242ad885c5ba376d960a352108b2ef4d116930fb4dc432

Contents?: true

Size: 1.03 KB

Versions: 107

Compression:

Stored size: 1.03 KB

Contents

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

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
scrivito_sdk-0.71.0 lib/scrivito/log_subscriber.rb
scrivito_sdk-0.71.0.rc2 lib/scrivito/log_subscriber.rb
scrivito_sdk-0.71.0.rc1 lib/scrivito/log_subscriber.rb
scrivito_sdk-0.70.0 lib/scrivito/log_subscriber.rb
scrivito_sdk-0.70.0.rc3 lib/scrivito/log_subscriber.rb
scrivito_sdk-0.70.0.rc2 lib/scrivito/log_subscriber.rb
scrivito_sdk-0.70.0.rc1 lib/scrivito/log_subscriber.rb