Class: Hpe3parSdk::CustomHTTPFormatter
- Inherits:
-
Object
- Object
- Hpe3parSdk::CustomHTTPFormatter
- Defined in:
- lib/Hpe3parSdk/multi_log.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#current_time ⇒ Object
Returns the value of attribute current_time.
-
#level ⇒ Object
Returns the value of attribute level.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #format(request, response) ⇒ Object
-
#initialize(logger, level) ⇒ CustomHTTPFormatter
constructor
A new instance of CustomHTTPFormatter.
Constructor Details
#initialize(logger, level) ⇒ CustomHTTPFormatter
Returns a new instance of CustomHTTPFormatter.
72 73 74 75 |
# File 'lib/Hpe3parSdk/multi_log.rb', line 72 def initialize(logger, level) @logger = logger @level = level.to_sym end |
Instance Attribute Details
#current_time ⇒ Object
Returns the value of attribute current_time.
70 71 72 |
# File 'lib/Hpe3parSdk/multi_log.rb', line 70 def current_time @current_time end |
#level ⇒ Object
Returns the value of attribute level.
70 71 72 |
# File 'lib/Hpe3parSdk/multi_log.rb', line 70 def level @level end |
#logger ⇒ Object
Returns the value of attribute logger.
70 71 72 |
# File 'lib/Hpe3parSdk/multi_log.rb', line 70 def logger @logger end |
Instance Method Details
#format(request, response) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/Hpe3parSdk/multi_log.rb', line 77 def format(request, response) http_method = request.http_method.name.split("::").last.upcase path = request.path.to_s content_length = response.respond_to?(:headers) ? response.headers['Content-Length'] : response['Content-Length'] @logger.send @level, "[#{response.code} #{http_method} #{path} #{content_length || '-'} ]" end |