Skip to content

Replace print() with structured logging via rich#88

Open
tabedzki wants to merge 6 commits into
masterfrom
modify-to-logging
Open

Replace print() with structured logging via rich#88
tabedzki wants to merge 6 commits into
masterfrom
modify-to-logging

Conversation

@tabedzki

Copy link
Copy Markdown
Contributor

Summary

  • Adds rich>=15.0.0 as a core dependency for formatted log output
  • Introduces u19_pipeline/utils/logging_config.py with 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 entrypoints
  • Converts all active print() calls across ~35 files to appropriately levelled logger.debug/info/warning/error/exception calls
  • Wraps scripts/ingest_hdf5_to_db.py in main() + if __name__ == "__main__": so it is safe to import without executing
  • scripts/conf_file_finding.py is a pure utility module — no setup_logging() call, safe for downstream repos to import

Design 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 call setup_logging() at their __main__ entry point to get Rich-formatted output.

Test plan

  • Run a script directly (python scripts/rig_maintenance_demo.py) and confirm Rich-formatted log output appears
  • Import a library module (from u19_pipeline.utils.ephys_utils import ...) in a Python session without calling setup_logging() and confirm no output is produced
  • Confirm uv sync / pip install -e . picks up rich without issues

🤖 Generated with Claude Code

tabedzki and others added 6 commits June 11, 2026 21:38
- 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>
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