6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ja/debug_logger.rb', line 6
def perform(req, options)
Ja.logger.debug {
lines = ["Sending #{req.verb.to_s.upcase} to #{req.uri.to_s.inspect}"]
lines << "\e[36m"
lines << req.headline
lines += req..map { |key, value| "#{key}: #{value}" }
body = Ja.format_body(req.) {
buffer = ""
req.body.each { |chunk| buffer << chunk }
buffer
}
lines.join("\n") + "\n\n" + body + "\n\e[0m\n"
}
res = super
Ja.logger.debug {
lines = ["Response from #{req.verb.to_s.upcase} to #{req.uri.to_s.inspect}"]
lines << "\e[35m"
lines << "HTTP/#{res.instance_variable_get(:@version)} #{res.status}"
lines += res..map { |key, value| "#{key}: #{value}" }
body = Ja.format_body(res.) { res.body.to_s }
lines.join("\n") + "\n\n" + body + "\n\e[0m\n"
}
res
end
|