Skip to content
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

Refactor logging via "Loggable" trait #15789

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

uberbrady
Copy link
Collaborator

This is an experiment; we don't have to take this if we don't want.

First things first, I moved the "Loggable" trait into the Traits subdirectory.

I then tried to move a lot of the functionality of the "Loggable" trait into the Boot method of the trait itself, rather than relying on Observers to power it all. I was able to delete all of the observers - taking the shared Loggable functionality out into the Trait, and taking the object-specific functionality into the boot method of the object in question.

This helps by making the code that 'does the thing' physically close to 'the thing'. You don't have to open another file.

There is a ton of clean-up still to do, and there are new things I want to add, and a ton of FIXME comments that need addressing. And while all tests do pass, this changes a huge chunk of the functionality of the app, so there would have to be a TON of testing before we could take something like this.

But I needed a distraction so I made this.

Copy link

what-the-diff bot commented Nov 8, 2024

PR Summary

  • Enhanced System Flexibility with New Enum Type: A new ActionType enum is introduced that unlocks various action cases to be used across the application. This streamlines certain processes such as restore actions, two-factor reset logic, bulk item actions, and request actions.

  • Improved Logging across Controllers: A shift was achieved across multiple controllers from creating new Actionlog instances, which is a slightly cumbersome process, to using a more efficient setLogMessage method. This improves consistency and makes the application more maintainable.

  • Addition of Powerful 'Loggable' Trait Across Inventory Types: The inclusion of a Loggable trait in various inventory items like Assets, Asset Models, Components, Consumables, Licences, and Users will facilitate enhanced logging capabilities. This will be especially useful as it aids a comprehensive logging mechanism during regular model events such as creation, update, and deletion.

  • Renaming and Improving Loggable for Enhanced Functionality: The Loggable has been moved to a trait and updated to include robust logging capabilities, allowing for better tracking of model events.

  • Removal of Observers and Migration to Model-Integrated Logging: Several observer classes, that were previously relied on for observing events and actions on various models, have been removed. This is due to the newly added logging system integrated directly into the models, simplifying and streamlining logging actions.

  • Logging Augmentation in Test Cases: Improved logging statements have been added to test files to aid debugging. Test assertions too have been refactored to provide clearer debugging messages.

  • Improved User Merge Operation Testing: Logging was added to capture important user details during the merge operation. Assertions were also included to ensure users involved in the merge operation behaved as expected, enhancing operational safety.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant