First try at changing the logging facilities#544
Draft
Hugovdberg wants to merge 6 commits intopypest:developfrom
Draft
First try at changing the logging facilities#544Hugovdberg wants to merge 6 commits intopypest:developfrom
Hugovdberg wants to merge 6 commits intopypest:developfrom
Conversation
Collaborator
|
Hey @Hugovdberg, I think you would have to modify or remove this test, utils_test.py::run_sp_capture_output_test, for the CI workflow to work with the new logging capabilities. Sorry that test was pretty ad-hoc |
Author
|
Probably a lot of tests will fail once we add this in other places as well :-) testing output is always troublesome.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ages ago I proposed to migrate to the built in logging facilities to allow for more flexible logging (see #315). Recently I have been using
pyemuagain and faced the same issue I faced then so here is a PR (work in progress) to add logging instead of writing files directly.I decided to first tackle the new
run_spmethod as this was the newest so least likely to break peoples workflows should it be not as stable as I think it is (see #539 / #532).What I have done is create a little method that returns alogging.Loggerobject given the boolean flagsverboseandlogger(which currently is calledlogfilein other methods). However,loggercan also accept alogging.Loggerobject directly. So if you run something like the following code, all messages are recorded inmy_custom.loginstead ofpyemu.log:I have added two helpers, one is
pyemu.log_utils.get_loggerthat returns alogging.Loggerobject that writes topyemu.logor stdout when requested. The second ispyemu.log_utils.set_loggerthat either takes alogging.Logger(as a positional only argument) or keyword arguments that are passed directly tologging.basicConfig:Of course you can go all out in how complicated you want your logging facilities to be, see https://docs.python.org/3/library/logging.html# for all possibilities.