Skip to content

Log through pyprep's own logger namespace - #209

Merged
sappelhoff merged 2 commits into
mainfrom
logging-namespace
Aug 8, 2026
Merged

Log through pyprep's own logger namespace#209
sappelhoff merged 2 commits into
mainfrom
logging-namespace

Conversation

@sappelhoff

Copy link
Copy Markdown
Owner

pyprep used three logging mechanisms at once: find_noisy_channels and ransac logged
through MNE's logger (from mne.utils import logger), reference through a handler-less
pyprep.reference logger, and removeTrend straight to the root logger. So pyprep's
records were attributed to mne, could only be silenced through mne.set_log_level, and two
of them surfaced as WARNING:root:....

pyprep now owns a pyprep logger, configured when the package is imported: INFO, its own
handler on sys.stdout, propagate = False. That is the model MNE uses for its own logger,
and the root logger stays untouched. setup_logging is the knob:

pyprep.setup_logging("WARNING")       # warnings and errors only
pyprep.setup_logging(propagate=True)  # let the application's handlers print them

Behaviour change

mne.set_log_level() no longer affects pyprep. Downstream code that relied on it — including
the two examples and the test fixtures in this repo — needs pyprep.setup_logging() instead.
The changelog says so.

Notes

  • The four logger.info calls in reference become visible for the first time.
  • removeTrend's message said "detreding"; fixed while touching the line.
  • tests/conftest.py gains an autouse fixture that quiets pyprep for the suite and restores
    propagation, without which caplog cannot see pyprep records at all: they no longer reach
    the root-level handler pytest installs.

Verification

pytest: 53 passed. In a fresh interpreter with no logging configuration, import pyprep is
now enough to get formatted [INFO] pyprep.<module>: ... on stdout, while
logging.getLogger().handlers is still [].

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

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.92%. Comparing base (f0e2fae) to head (8773bc4).

Files with missing lines Patch % Lines
pyprep/removeTrend.py 33.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sappelhoff
sappelhoff merged commit 266688c into main Aug 8, 2026
8 of 10 checks passed
@sappelhoff
sappelhoff deleted the logging-namespace branch August 8, 2026 10:14
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