Show where redirect was called from with "verbose redirect logs" setting

Sometimes it can be confusing where a redirect happened. It could’ve happened in one of the before_actions, somewhere in the logic of your controller method itself, or even in your routes file.

ActiveRecord has a nice “verbose query logs” feature that adds a line to the log with where the query was called from. I want to propose something similar for redirects. It could look something like this:

Started GET "/redirect" for at 2021-10-21 13:11:33 +0200
Processing by RegularController#redirect as */*
Redirected to http://localhost:3000/moo
  ↳ app/controllers/regular_controller.rb:15
Completed 302 Found in 0ms (ActiveRecord: 0.0ms | Allocations: 414)

If this is something worth adding I’d like to write some code and get a PR up.

I think there is also some discussion needed around if a separate config setting is wanted, or that stuff can be moved to a more generic config setting (“verbose logs”? “verbose source location logs”?). I’m not sure what direction to take it in that regard, though. Feedback is welcome!