Make request completed log line complete
This commit is contained in:
parent
e09b544f26
commit
0fa93706a6
2 changed files with 21 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ class ActionView::LogSubscriber
|
||||||
message = "event=render "
|
message = "event=render "
|
||||||
message << "template=#{from_rails_root(event.payload[:identifier])} "
|
message << "template=#{from_rails_root(event.payload[:identifier])} "
|
||||||
message << "layout=#{from_rails_root(event.payload[:layout])} " if event.payload[:layout]
|
message << "layout=#{from_rails_root(event.payload[:layout])} " if event.payload[:layout]
|
||||||
message << "time=#{("%.1fms" % event.duration)}"
|
message << "ms=#{("%.1f" % event.duration)}"
|
||||||
Rails.logger.info(message)
|
Rails.logger.info(message)
|
||||||
end
|
end
|
||||||
alias :render_partial :render_template
|
alias :render_partial :render_template
|
||||||
|
|
@ -22,10 +22,13 @@ class ActionController::LogSubscriber
|
||||||
def process_action(event)
|
def process_action(event)
|
||||||
payload = event.payload
|
payload = event.payload
|
||||||
additions = ActionController::Base.log_process_action(payload)
|
additions = ActionController::Base.log_process_action(payload)
|
||||||
|
params = payload[:params].except(*INTERNAL_PARAMS)
|
||||||
|
|
||||||
log_string = "event=request_completed status=#{payload[:status]} "
|
log_string = "event=request_completed status=#{payload[:status]} "
|
||||||
log_string << "hstatus=#{Rack::Utils::HTTP_STATUS_CODES[payload[:status]]} time=#{"%.0fms" % event.duration} "
|
log_string << "controller=#{payload[:controller]} action=#{payload[:action]} format=#{payload[:formats].first.to_s.upcase} "
|
||||||
log_string << " (#{additions.join(" | ")})" unless additions.blank?
|
log_string << "ms=#{"%.0f" % event.duration} "
|
||||||
|
log_string << "params='#{params.inspect}' " unless params.empty?
|
||||||
|
log_string << "additions='#{additions.join(" | ")}'" unless additions.blank?
|
||||||
|
|
||||||
Rails.logger.info(log_string)
|
Rails.logger.info(log_string)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@ describe HomeController do
|
||||||
it 'logs params' do
|
it 'logs params' do
|
||||||
@line.include?("params='{\"lasers\"=>\"green\"}'").should be_true
|
@line.include?("params='{\"lasers\"=>\"green\"}'").should be_true
|
||||||
end
|
end
|
||||||
|
it 'logs format' do
|
||||||
|
@line.include?("format=html")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
context 'completion' do
|
context 'completion' do
|
||||||
context 'ok' do
|
context 'ok' do
|
||||||
|
|
@ -63,6 +66,18 @@ describe HomeController do
|
||||||
it 'logs an ok' do
|
it 'logs an ok' do
|
||||||
@line.include?('status=200').should be_true
|
@line.include?('status=200').should be_true
|
||||||
end
|
end
|
||||||
|
it 'logs the controller' do
|
||||||
|
@line.include?('controller=HomeController').should be_true
|
||||||
|
end
|
||||||
|
it 'logs the action' do
|
||||||
|
@line.include?('action=show').should be_true
|
||||||
|
end
|
||||||
|
it 'logs params' do
|
||||||
|
@line.include?("params='{\"lasers\"=>\"green\"}'").should be_true
|
||||||
|
end
|
||||||
|
it 'does not log the view rendering time addition' do
|
||||||
|
@line.include?("(Views: ").should be_false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
context 'redirected' do
|
context 'redirected' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue