Module: DevSuite::RequestLogger::Logger

Defined in:
lib/dev_suite/request_logger/logger.rb

Class Method Summary collapse

Class Method Details

.log_request(instance, request) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/dev_suite/request_logger/logger.rb', line 7

def log_request(instance, request)
  request = extract_request(instance, request)
  log_entry(format_request_line(instance, request), :start)
  log_headers(request) if settings.get(:log_headers)
  log_cookies(request) if settings.get(:log_cookies)
  log_body(request.body, "Request") if settings.get(:log_body)
end

.log_response(instance, response) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/dev_suite/request_logger/logger.rb', line 15

def log_response(instance, response)
  response = extract_response(instance, response)
  status_emoji = determine_status_emoji(response)
  log_level = determine_log_level(response)

  log_entry(format_response_line(instance, response), status_emoji, log_level)
  log_headers(response) if settings.get(:log_headers)
  log_body(response.body, "Response") if settings.get(:log_body)
  log_response_time(response) if settings.get(:log_response_time)
end