Class: VCR::Logger
- Inherits:
-
Object
- Object
- VCR::Logger
- Defined in:
- lib/vcr/util/logger.rb
Overview
Provides log message formatting helper methods.
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(stream) ⇒ Logger
constructor
A new instance of Logger.
- #log(message, log_prefix, indentation_level = 0) ⇒ Object
- #request_summary(request, request_matchers) ⇒ Object
- #response_summary(response) ⇒ Object
Constructor Details
#initialize(stream) ⇒ Logger
Returns a new instance of Logger.
5 6 7 |
# File 'lib/vcr/util/logger.rb', line 5 def initialize(stream) @stream = stream end |
Instance Method Details
#log(message, log_prefix, indentation_level = 0) ⇒ Object
9 10 11 12 13 |
# File 'lib/vcr/util/logger.rb', line 9 def log(, log_prefix, indentation_level = 0) indentation = ' ' * indentation_level = indentation + log_prefix + @stream.puts end |
#request_summary(request, request_matchers) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/vcr/util/logger.rb', line 15 def request_summary(request, request_matchers) attributes = [request.method, request.uri] attributes << request.body.to_s[0, 80].inspect if request_matchers.include?(:body) attributes << request.headers.inspect if request_matchers.include?(:headers) "[#{attributes.join(" ")}]" end |
#response_summary(response) ⇒ Object
22 23 24 |
# File 'lib/vcr/util/logger.rb', line 22 def response_summary(response) "[#{response.status.code} #{response.body[0, 80].inspect}]" end |