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

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, error) ⇒ Object



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

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