Log through pyprep's own logger namespace - #209
Merged
Conversation
pyprep now owns a `pyprep` logger, configured at import to log at INFO through its own stdout handler, with the new `setup_logging()` as the knob for level, stream, and handing the records over to the application. The root logger is never configured. `find_noisy_channels` and `ransac` used MNE's logger, so their records were attributed to `mne` and could only be silenced through `mne.set_log_level`. `removeTrend` logged to the root logger, which escaped every silencing mechanism and printed as `WARNING:root:`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
==========================================
+ Coverage 97.85% 97.92% +0.06%
==========================================
Files 7 8 +1
Lines 841 869 +28
==========================================
+ Hits 823 851 +28
Misses 18 18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
pyprepused three logging mechanisms at once:find_noisy_channelsandransacloggedthrough MNE's logger (
from mne.utils import logger),referencethrough a handler-lesspyprep.referencelogger, andremoveTrendstraight to the root logger. So pyprep'srecords were attributed to
mne, could only be silenced throughmne.set_log_level, and twoof them surfaced as
WARNING:root:....pyprep now owns a
pypreplogger, configured when the package is imported:INFO, its ownhandler on
sys.stdout,propagate = False. That is the model MNE uses for its own logger,and the root logger stays untouched.
setup_loggingis the knob:Behaviour change
mne.set_log_level()no longer affects pyprep. Downstream code that relied on it — includingthe two examples and the test fixtures in this repo — needs
pyprep.setup_logging()instead.The changelog says so.
Notes
logger.infocalls inreferencebecome visible for the first time.removeTrend's message said "detreding"; fixed while touching the line.tests/conftest.pygains an autouse fixture that quiets pyprep for the suite and restorespropagation, without which
caplogcannot see pyprep records at all: they no longer reachthe root-level handler pytest installs.
Verification
pytest: 53 passed. In a fresh interpreter with no logging configuration,import pyprepisnow enough to get formatted
[INFO] pyprep.<module>: ...on stdout, whilelogging.getLogger().handlersis still[].