janko / rodauth-rails

Rails integration for Rodauth authentication framework
https://github.com/jeremyevans/rodauth
MIT License
584 stars 40 forks source link

Add controller-like request logging #42

Closed janko closed 3 years ago

janko commented 3 years ago

The Rails::Rack::Logger middleware already logs each request on the URL level, and view rendering is being logged as well. However, requests to controller actions also display:

Processing by MyController#some_action as HTML
# ...view render logging...
Completed 200 OK in 12ms (...more info...)

We want the same kind of nice logging for Rodauth requests, to communicate to the developer that the RodauthApp middleware has indeed caught the request, what was response status, and how long the whole request took.

We implement this using the same approach that Action Pack uses to implement controller-level logging. Now the developer sees this for a Rodauth request:

Started GET "/create-account" for 127.0.0.1 at 2021-05-06 17:46:12 +0200
Processing by RodauthApp as HTML
# ...view render logging...
Completed 200 OK in 15ms (ActiveRecord: 0.0ms | Allocations: 2443)