Class: Rack::Logjam::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/logjam/logger.rb

Instance Method Summary collapse

Instance Method Details

#log_request(env) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/rack/logjam/logger.rb', line 8

def log_request( env )
  _logger.info <<-end_info
[#{ANSI.green { 'api' }}] #{ANSI.cyan { '--- Request Env ---' }}
#{ANSI.magenta { JSON.pretty_generate( request_log_data( env )) }}
[#{ANSI.green { 'api' }}] #{ANSI.cyan { '--- Request Body ---' }}
#{ANSI.cyan { formatted_request_body( env ) }}
end_info
end

#log_response(env, status, headers, response) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/rack/logjam/logger.rb', line 17

def log_response( env, status, headers, response )
  _logger.info <<-end_info
[#{ANSI.green { 'api' }}] #{ANSI.cyan { '--- Response ---' }}
Status: #{status}
Headers: #{headers.inspect}
Body:
#{ANSI.cyan { format_body( (response.body rescue response), accept( env ), env ) }}
  end_info
end