Sha256: 90e7294334b676c6befa480f536869eaab87efd80d57b23f1ab811cfa9a4736e

Contents?: true

Size: 709 Bytes

Versions: 22

Compression:

Stored size: 709 Bytes

Contents

module ActiveFedora
  class LogSubscriber < ActiveSupport::LogSubscriber

    def initialize
      super
      @odd = false
    end

    def ldp(event)
      return unless logger.debug?

      payload = event.payload

      name  = "#{payload[:name]} (#{event.duration.round(1)}ms)"
      id   = payload[:id] || "[no id]"

      if odd?
        name = color(name, CYAN, true)
        id  = color(id, nil, true)
      else
        name = color(name, MAGENTA, true)
      end

      debug "  #{name} #{id} Service: #{payload[:ldp_service]}"
    end

    def odd?
      @odd = !@odd
    end

    def logger
      ActiveFedora::Base.logger
    end
  end
end

ActiveFedora::LogSubscriber.attach_to :active_fedora

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
active-fedora-9.0.8 lib/active_fedora/log_subscriber.rb
active-fedora-9.5.0 lib/active_fedora/log_subscriber.rb
active-fedora-9.4.3 lib/active_fedora/log_subscriber.rb
active-fedora-9.4.2 lib/active_fedora/log_subscriber.rb
active-fedora-9.4.1 lib/active_fedora/log_subscriber.rb
active-fedora-9.4.0 lib/active_fedora/log_subscriber.rb
active-fedora-9.3.0 lib/active_fedora/log_subscriber.rb
active-fedora-9.2.1 lib/active_fedora/log_subscriber.rb
active-fedora-9.2.0 lib/active_fedora/log_subscriber.rb
active-fedora-9.2.0.rc2 lib/active_fedora/log_subscriber.rb
active-fedora-9.2.0.rc1 lib/active_fedora/log_subscriber.rb
active-fedora-9.1.2 lib/active_fedora/log_subscriber.rb
active-fedora-9.1.1 lib/active_fedora/log_subscriber.rb
active-fedora-9.1.0 lib/active_fedora/log_subscriber.rb
active-fedora-9.1.0.rc1 lib/active_fedora/log_subscriber.rb
active-fedora-9.0.6 lib/active_fedora/log_subscriber.rb
active-fedora-9.0.5 lib/active_fedora/log_subscriber.rb
active-fedora-9.0.4 lib/active_fedora/log_subscriber.rb
active-fedora-9.0.3 lib/active_fedora/log_subscriber.rb
active-fedora-9.0.2 lib/active_fedora/log_subscriber.rb