Class: RestClient::Jogger::RequestComplete

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/rest_client/jogger/request_complete.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ RequestComplete

Returns a new instance of RequestComplete.



7
8
9
10
# File 'lib/rest_client/jogger/request_complete.rb', line 7

def initialize(args = {})
  self.logger = args.fetch :logger
  super
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/rest_client/jogger/request_complete.rb', line 5

def logger
  @logger
end

#notifierObject

Returns the value of attribute notifier.



5
6
7
# File 'lib/rest_client/jogger/request_complete.rb', line 5

def notifier
  @notifier
end

Instance Method Details

#call(name, start, finish, id, payload) ⇒ Object



16
17
18
19
20
21
# File 'lib/rest_client/jogger/request_complete.rb', line 16

def call(name, start, finish, id, payload)
  message = ::JSON.dump(payload.merge(event_name: name, event_id: id, timestamp: start))
  name =~ /error/ ? logger.error(message) : logger.debug(message)
rescue StandardError => e
  notifier.error e, payload: payload
end