Class: PactBroker::Webhooks::WebhookRequestLogger
- Inherits:
-
Object
- Object
- PactBroker::Webhooks::WebhookRequestLogger
- Includes:
- Logging
- Defined in:
- lib/pact_broker/webhooks/webhook_request_logger.rb
Defined Under Namespace
Classes: Formatter
Instance Attribute Summary collapse
-
#execution_logger ⇒ Object
readonly
Returns the value of attribute execution_logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ WebhookRequestLogger
constructor
A new instance of WebhookRequestLogger.
-
#log(uuid, webhook_request, http_response, success, error, webhook_context) ⇒ Object
rubocop: disable Metrics/ParameterLists.
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() @log_stream = StringIO.new @execution_logger = Logger.new(log_stream) @execution_logger.formatter = Formatter.new @options = end |
Instance Attribute Details
#execution_logger ⇒ Object (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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/pact_broker/webhooks/webhook_request_logger.rb', line 11 def @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 (success) log_stream.string end |