collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.34k stars 645 forks source link

Audits with line of code location #691

Open ali-ehmed opened 5 months ago

ali-ehmed commented 5 months ago

We recently have been checking the audits table to find out a cause of an unexpected update operation. We weren't expecting one of the attribute of a model to get updated and eventually sending out emails, but we came to know that there's was a separate entry of that update action in the table and since our code base is very big, it was hard to debug the location of that update operation. This scenario made me wondered if there could be a way to also store a class name and line of code as well so that it becomes easier to debug sometimes why/where operations are performed by checking out the logic.

So a new column action_location or something that will store a file name with a line of code e.g app/services/update_user.rb#L56.

I'm not really sure how useful it would be to add this support in the audited engine but I'd love to know more thoughts on this from others.

danielmorrison commented 5 months ago

Based on how Audited hooks into Rails, I'm not sure how easy it would be to accomplish what you want. Open to PRs though.

Alternately, you could make liberal use of comments to leave yourself breadcrumbs.