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

Overhaul logging to avoid package level var #963

Merged
merged 1 commit into from
May 13, 2021

Conversation

sysadmind
Copy link
Contributor

This converts all logging calls to a logrus instance that is passed into types or functions instead of a package level variable. This is to help prevent any possible race conditions with the variable and it also helps show the dependency on logging for each type instead of an implicit reference.

Originally I attempted to abstract a logging interface away from logrus but so much of the logrus API is being used that it was quite difficult to abstract away and there was not much direct benefit from doing so. The tests are all passing and I did test running docker-compose locally. I can add jobs via the UI and execute them with no panics. I feel relatively confident with these changes, but I'm not sure how complete the test coverage is in order to prove that.

I'm open to feedback here if there are improvements that can be made. The Job logging calls felt the most difficult because the Run method is not allowed to have parameters so I had to have the scheduler set the logger on the jobs before returning them.

This helps improve #951

This converts all logging calls to a logrus instance that is passed into types or functions instead of a package level variable. This is to help prevent any possible race conditions with the variable and it also helps show the dependency on logging for each type instead of an implicit reference.

Originally I attempted to abstract a logging interface away from logrus but so much of the logrus API is being used that it was quite difficult to abstract away and there was not much direct benefit from doing so. The tests are all passing and I did test running docker-compose locally. I can add jobs via the UI and execute them with no panics. I feel relatively confident with these changes, but I'm not sure how complete the test coverage is in order to prove that.
Copy link
Member

@vcastellm vcastellm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thx!

@vcastellm vcastellm merged commit 3ea5124 into distribworks:master May 13, 2021
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.

2 participants