Class: ActiveFedora::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/active_fedora/log_subscriber.rb

Instance Method Summary collapse

Constructor Details

#initializeLogSubscriber

Returns a new instance of LogSubscriber


4
5
6
7
# File 'lib/active_fedora/log_subscriber.rb', line 4

def initialize
  super
  @odd = false
end

Instance Method Details

#ldp(event) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_fedora/log_subscriber.rb', line 9

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

#loggerObject


31
32
33
# File 'lib/active_fedora/log_subscriber.rb', line 31

def logger
  ActiveFedora::Base.logger
end

#odd?Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/active_fedora/log_subscriber.rb', line 27

def odd?
  @odd = !@odd
end