rails-template icon indicating copy to clipboard operation
rails-template copied to clipboard

Implement a basic audit logger

Open eoinkelly opened this issue 3 years ago • 4 comments

  • 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

eoinkelly avatar Oct 07 '22 03:10 eoinkelly

This is extracted from some previous implementations of this kind of feature. Discussion welcome.

eoinkelly avatar Oct 07 '22 03:10 eoinkelly

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

eoinkelly avatar Oct 09 '22 18:10 eoinkelly

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.

eoinkelly avatar Oct 13 '22 21:10 eoinkelly

After our team discussion yesterday, I have rewritten this to be dramatically simpler. Feedback on the API design is welcome

eoinkelly avatar Oct 22 '22 00:10 eoinkelly

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.

G-Rath avatar Oct 22 '22 20:10 G-Rath

I go back and forth about whether this belongs in the template. Let's discuss at next meeting.

eoinkelly avatar Mar 25 '23 02:03 eoinkelly

A summary of available community options https://blog.appsignal.com/2023/04/12/audit-logging-in-ruby-and-rails.html

eoinkelly avatar Apr 14 '23 02:04 eoinkelly