Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/lograge/log_subscribers/action_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# frozen_string_literal: true

require 'action_controller'

module Lograge
module LogSubscribers
class ActionController < Base
def process_action(event)
::ActionController::Base.log_process_action(event.payload)
process_main_event(event)
end

Expand Down
9 changes: 9 additions & 0 deletions spec/log_subscribers/action_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@
end
end

context 'with a status code that is set in log_process_action (devise)' do
it 'returns the correct status code' do
allow(::ActionController::Base).to receive(:log_process_action) { |payload| payload[:status] = 401 }
event.payload[:status] = nil
subscriber.process_action(event)
expect(log_output.string).to match(/status=401 /)
end
end

it "will fallback to ActiveSupport's logger if one isn't configured" do
Lograge.formatter = Lograge::Formatters::KeyValue.new
Lograge.logger = nil
Expand Down