Replace print() with structured logging via rich#88
Open
tabedzki wants to merge 6 commits into
Open
Conversation
- Add rich>=15.0.0 to dependencies - Add u19_pipeline/utils/logging_config.py with get_logger() (library-safe, no handler setup) and setup_logging() (Rich handler for script entrypoints) - Root logger gets a NullHandler so library imports are silent by default - Convert all active print() calls to logger.debug/info/warning/error/exception across ~35 files in u19_pipeline/ and scripts/ - Wrap scripts/ingest_hdf5_to_db.py in main() + __main__ guard so it is safe to import; setup_logging() called only at script entry - scripts/rig_maintenance_demo.py: setup_logging() in __main__ block - scripts/conf_file_finding.py: pure utility module, no setup_logging() call Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
rich>=15.0.0as a core dependency for formatted log outputu19_pipeline/utils/logging_config.pywith two functions:get_logger(name)— library-safe, never configures handlers (follows PEP 396 NullHandler convention)setup_logging(level)— installs a Rich handler on the root logger; called only at script entrypointsprint()calls across ~35 files to appropriately levelledlogger.debug/info/warning/error/exceptioncallsscripts/ingest_hdf5_to_db.pyinmain()+if __name__ == "__main__":so it is safe to import without executingscripts/conf_file_finding.pyis a pure utility module — nosetup_logging()call, safe for downstream repos to importDesign rationale
Library code (
u19_pipeline/) never configures the root logger. Downstream repos that import this package won't have their own logging setup overwritten. Scripts (scripts/) that are run directly callsetup_logging()at their__main__entry point to get Rich-formatted output.Test plan
python scripts/rig_maintenance_demo.py) and confirm Rich-formatted log output appearsfrom u19_pipeline.utils.ephys_utils import ...) in a Python session without callingsetup_logging()and confirm no output is produceduv sync/pip install -e .picks uprichwithout issues🤖 Generated with Claude Code