Class: Morpheus::Client::LogSubscriber

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

Instance Method Summary collapse

Constructor Details

#initializeLogSubscriber

Returns a new instance of LogSubscriber.



5
6
7
8
# File 'lib/morpheus/client/log_subscriber.rb', line 5

def initialize
  super
  @odd_or_even = false
end

Instance Method Details

#cached_request(event) ⇒ Object



18
19
20
# File 'lib/morpheus/client/log_subscriber.rb', line 18

def cached_request(event)
  CachedRequestFormatter.call(self, event, odd?)
end

#loggerObject



28
29
30
# File 'lib/morpheus/client/log_subscriber.rb', line 28

def logger
  Morpheus::Configuration.logger
end

#odd?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/morpheus/client/log_subscriber.rb', line 32

def odd?
  @odd_or_even = !@odd_or_even
end

#payload(event) ⇒ Object



22
23
24
25
26
# File 'lib/morpheus/client/log_subscriber.rb', line 22

def payload(event)
  payload  = "#{event.payload[:url]}"
  payload << " #{event.payload[:params].inspect}" unless event.payload[:params].blank?
  payload
end

#request(event) ⇒ Object



10
11
12
# File 'lib/morpheus/client/log_subscriber.rb', line 10

def request(event)
  debug "  #{event.payload[:response].cached? ? cached_request(event) : uncached_request(event)}"
end

#uncached_request(event) ⇒ Object



14
15
16
# File 'lib/morpheus/client/log_subscriber.rb', line 14

def uncached_request(event)
  UncachedRequestFormatter.call(self, event, odd?)
end