Implement a basic audit logger
- Events are logged as JSON to a file
- Each auditable event corrseponds to a new type under Auditor::Event
- Audit logging is encapsulated behind the Auditor class so can be changed later without changing call-sites
Closes #340
This is extracted from some previous implementations of this kind of feature. Discussion welcome.
I have some doubts about whether inheritance is the best approach for creating each new event. It seems like a pretty heavy approach for just creating a hash with some different keys. I'm going to try some other, lighter, approaches
We are trying using https://github.com/collectiveidea/audited on a client project (client's needs are more than an off-box audit trail). Audited has callbacks which could be used to generate a log file. This might be a more elegant solution than what I have here so we'll see how it evolves.
After our team discussion yesterday, I have rewritten this to be dramatically simpler. Feedback on the API design is welcome
I think it would be good to include a couple of the real-world events that we know we'll want to include in variants like devise and sidekiq, in order to dogfood the design and make it easier to review.
I go back and forth about whether this belongs in the template. Let's discuss at next meeting.
A summary of available community options https://blog.appsignal.com/2023/04/12/audit-logging-in-ruby-and-rails.html