Skip to content

Sub logging support to fancylog#93

Open
HARSHDIPSAHA wants to merge 6 commits intoneuroinformatics-unit:mainfrom
HARSHDIPSAHA:sublog
Open

Sub logging support to fancylog#93
HARSHDIPSAHA wants to merge 6 commits intoneuroinformatics-unit:mainfrom
HARSHDIPSAHA:sublog

Conversation

@HARSHDIPSAHA
Copy link

@HARSHDIPSAHA HARSHDIPSAHA commented Feb 27, 2026

Before submitting a pull request (PR), please read the contributing guide.

Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
Introduce sublogging.
What does this PR do?
This pr adds a sublog feature whose parent will a main logger to consistently and easy manage and analyse loggings in heirarchial form.
adds SubLog and the sub_log context manager to fancylog, addressing both parts of the feature request:

  • Separate log files per pipeline step, each linked from the main log
  • Subprocess capture — stdout/stderr from third-party tools (e.g. NiftyReg, elastix) are routed into their own sub-log

References

#66

How has this PR been tested?

using pytest on added tests.

Is this a breaking change?

No

Does this PR require an update to the documentation?

Maybe

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@HARSHDIPSAHA
Copy link
Author

HARSHDIPSAHA commented Feb 28, 2026

example use

import fancylog
from fancylog.sublog import sub_log

fancylog.start_logging(output_dir, fancylog, logger_name="pipeline")

with sub_log("registration", output_dir, parent_logger_name="pipeline") as sl:
    sl.logger.info("Starting atlas registration")
    sl.run_subprocess(["niftyreg", "-ref", "atlas.nii", "-flo", "brain.nii"])

Example output

fancylog_<timestamp>.log (main log — references only, no detail noise)

2026-02-28 16:17:54 PM - INFO - Starting sub-log 'preprocessing', see logs\preprocessing.log for details
2026-02-28 16:17:54 PM - INFO - Sub-log 'preprocessing' finished, log saved to logs\preprocessing.log
2026-02-28 16:17:54 PM - INFO - Starting sub-log 'registration', see logs\registration.log for details
2026-02-28 16:17:54 PM - INFO - Sub-log 'registration' finished, log saved to logs\registration.log
2026-02-28 16:17:54 PM - INFO - Starting sub-log 'external_tool', see logs\external_tool.log for details
2026-02-28 16:17:54 PM - INFO - Sub-log 'external_tool' finished, log saved to logs\external_tool.log

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 88.40580% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.35%. Comparing base (c987796) to head (7d880ff).

Files with missing lines Patch % Lines
fancylog/sublog.py 88.23% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #93      +/-   ##
==========================================
+ Coverage   77.72%   80.35%   +2.63%     
==========================================
  Files           3        4       +1     
  Lines         211      280      +69     
==========================================
+ Hits          164      225      +61     
- Misses         47       55       +8     

☔ View full report in Codecov by Sentry.
📢 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.

@HARSHDIPSAHA HARSHDIPSAHA marked this pull request as ready for review March 3, 2026 07:22
@HARSHDIPSAHA HARSHDIPSAHA marked this pull request as draft March 3, 2026 07:40
@HARSHDIPSAHA HARSHDIPSAHA marked this pull request as ready for review March 5, 2026 07:19
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