Skip to content

[UPDATED] Simpler logging refactor #16839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

uberbrady
Copy link
Member

@uberbrady uberbrady commented Apr 30, 2025

This is another version of #16779 - a little bit of a simpler approach. I think I like it.

Updated

This is now getting pretty close. The previously-made updates to tests have definitely helped to catch bugs in this implementation, which I'm pretty happy with.

Right now, we should see that there are still a few failing tests. These all boil down to different choices of implementation. Before this PR we weren't quite too rigid about logging things separately when they were created versus checked out. And we weren't too rigid about making sure that the API worked exactly the same as the GUI in these cases. But, should we be?

My opinion - creating an asset and immediately checking it out via GUI or API should both do the same thing - log a 'created' action_log and then immediately a 'checkout' action_log. I think the extra action_log entries make it clearer and easier to 'replay' the history of an object.

To-Do

  • I recently introduced - or, rather, sorta re-introduced, the Loggable method saveWithLogAction() (which I think is a dumb name, I should fix it). I should probably apply that across the code base for consistency.
  • This probably needs some extensive testing. It touches a lot of the 'heart' of Snipe-IT - the action_log. While it does try to ensure that some type of action_log happens any time the object-in-question gets modified, or if the various logging methods are called, it's possible that something could have been missed, or there are still subtle bugs around.
  • We could probably stand to do another squash - as there are a ton of commits. Unfortunately, the vrious 'squash' attempts I've made in the past seem to obscure the fact that the Loggable trait got moved into the Traits sub-directory, which has made later merges much, much harder.
  • Because of how git works, some changes that have happened to some of the files that have been deleted keep making those files pop back up when we try and re-merge develop into this branch. It's not always easy to see what the changes were to merge them back into wherever they belong. I've done my fair share of archeology to try and figure that out, but I could've easily missed something.

Next Steps

  1. I have two PR's waiting on this one, which will need to be re-pointed and updated to match this new 'style' of handling the action_logs:
  1. I think once all that is done and everything is merged, it will be the case that the events that we're firing are really only notification-triggers. If that's true, we might be able to fully "de-event" the notifications, and trigger them all directly with ->notify(). if that makes sense. I feel like the Slack/webhook notifications and the email notifications are sufficiently different that I would like to see if it's possible to split them off - but that might only work with the event'ed notifications, and not with the ->notify() based ones.
  2. I think this sets us up to do the 'quantitizable' changes that we've been pondering - having one grand-unified method of making all action_log entries makes it much easier to start to treat "quantities" as first-class fields and not simple repetitions.
  3. I think this also sets up some of the "Order" and "Purchase Order" additions that we've been considering simpler as well.
  4. This puts us in a good position to unify check-in, and checkout, perhaps as an Interface, or maybe as @spencerrlongg 's "Action" idea. But reducing duplicated code here is good.

@uberbrady uberbrady requested a review from snipe as a code owner April 30, 2025 15:51
@marcusmoore
Copy link
Collaborator

I also like this approach more than #16779. There are still a lot of todos and fixmes so I'm going to hold off on a full review besides just a few comments for anything I see on a quick skim.

@snipe
Copy link
Member

snipe commented May 27, 2025

Looks like you've got some tests failing in 8.2

@uberbrady uberbrady changed the title Simpler logging refactor [UPDATED] Simpler logging refactor Jul 24, 2025
@uberbrady
Copy link
Member Author

This is cleaned up heavily in #17463 - I'm closing this one.

@uberbrady uberbrady closed this Jul 24, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in Snipe-IT Awaiting Epic Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants