Module: TrackerHub::Request::Format::Logger
- Included in:
- TrackerHub::Request
- Defined in:
- lib/tracker_hub/request/format/logger.rb
Overview
Logger module formatting and rendering the request object
Instance Method Summary collapse
-
#cleaned_env ⇒ Utils::Env
Extract the rack env keys (see TrackerHub::Request::Config#required_keys) and convert them.
-
#serialized_env ⇒ Hash
Serialize objects before jsonifying them.
-
#to_logger ⇒ JSON
Format the response to the logger.
Instance Method Details
#cleaned_env ⇒ Utils::Env
Extract the rack env keys (see TrackerHub::Request::Config#required_keys)
and convert them
37 38 39 |
# File 'lib/tracker_hub/request/format/logger.rb', line 37 def cleaned_env response.slice(*Request.config.required_keys).merge(serialized_env) end |
#serialized_env ⇒ Hash
Serialize objects before jsonifying them
rubocop:disable AbcSize
53 54 55 56 57 58 59 60 61 |
# File 'lib/tracker_hub/request/format/logger.rb', line 53 def serialized_env { 'action_dispatch.logger' => response['action_dispatch.logger'].formatter.session_info, 'action_dispatch.remote_ip' => response['action_dispatch.remote_ip'].to_s, 'rack.session' => response['rack.session'].try(:to_hash), 'rack.session.options' => response['rack.session.options'].try(:to_hash), 'http_accept_language.parser' => response['http_accept_language.parser'].header } end |
#to_logger ⇒ JSON
Format the response to the logger
16 17 18 19 20 21 22 23 24 |
# File 'lib/tracker_hub/request/format/logger.rb', line 16 def to_logger { status: status, request: request, response: cleaned_env, app_version: Request.config.app_version, tracker_version: Request::VERSION }.to_json end |