Logging of parameters in Hanami

I am a big fan of hanami (http://hanamirb.org/). The architecture is very clean and my code is more testable.

However one thing I am missing is better logging. Parameter logging to be more precise. This is planned for version 1.1. But since I could not wait, I added a simple Rack middleware to do the job.

I am sharing this here to help anyone who is struggling as well. Please keep in mind that this might need to be modified to your needs.

The middleware logger can be configured with a logger and an array of parameters which should be filtered (eg. passwords).

I wrote a small mixin which initialises the middleware since I didn’t have access to the logger in application.rb. This mixin is included in every controller.

I hope this is helpful for some persons. Let me know if you have any questions and use at your own risk ;-)