Class: PactBroker::Webhooks::WebhookRequestLogger

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/pact_broker/webhooks/webhook_request_logger.rb

Defined Under Namespace

Classes: Formatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #log_with_tag, #measure_info

Constructor Details

#initialize(options) ⇒ WebhookRequestLogger

Returns a new instance of WebhookRequestLogger.



25
26
27
28
29
30
# File 'lib/pact_broker/webhooks/webhook_request_logger.rb', line 25

def initialize(options)
  @log_stream = StringIO.new
  @execution_logger = Logger.new(log_stream)
  @execution_logger.formatter = Formatter.new
  @options = options
end

Instance Attribute Details

#execution_loggerObject (readonly)

Returns the value of attribute execution_logger.



11
12
13
# File 'lib/pact_broker/webhooks/webhook_request_logger.rb', line 11

def execution_logger
  @execution_logger
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/pact_broker/webhooks/webhook_request_logger.rb', line 11

def options
  @options
end

Instance Method Details

#log(uuid, webhook_request, http_response, success, error, webhook_context) ⇒ Object

rubocop: disable Metrics/ParameterLists



33
34
35
36
37
38
39
40
41
# File 'lib/pact_broker/webhooks/webhook_request_logger.rb', line 33

def log(uuid, webhook_request, http_response, success, error, webhook_context)
  safe_response = http_response ? HttpResponseWithUtf8SafeBody.new(http_response) : nil
  log_webhook_context(webhook_context)
  log_request(webhook_request)
  log_response(uuid, safe_response, webhook_context[:base_url]) if safe_response
  log_error(uuid, error, webhook_context[:base_url]) if error
  log_completion_message(success)
  log_stream.string
end