Skip to content

Add @with_logging decorator to automate logging setup/teardown#646

Open
Pradyumn-cloud wants to merge 3 commits intoneuroinformatics-unit:mainfrom
Pradyumn-cloud:c1
Open

Add @with_logging decorator to automate logging setup/teardown#646
Pradyumn-cloud wants to merge 3 commits intoneuroinformatics-unit:mainfrom
Pradyumn-cloud:c1

Conversation

@Pradyumn-cloud
Copy link

FIX ISSUE - #548

This solves the issue where manual logging setup/teardown was error-prone and easy to forget for new public functions.

  • Created @with_logging decorator in decorators.py
  • Handles automatic log start/close with proper cleanup
  • Supports conditional logging via conditional_param parameter
  • Supports custom command names and temp folder storage
  • Ensures logging is closed even when exceptions occur
  • Uses finally block for exception safety

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

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

… This solves the issue where manual logging setup/teardown was

error-prone and easy to forget for new public functions.
@JoeZiminski
Copy link
Member

Hi @Pradyumn-cloud thanks for this! This looks really cool, you've covered all of the possible cases nicely. It will take me until next week to review in full, will get back to you ASAP! Cheers

@JoeZiminski
Copy link
Member

Hi @Pradyumn-cloud apologies for the delay with this, will definitely review by the end of this week

@JoeZiminski
Copy link
Member

Hi @Pradyumn-cloud sorry for the delay here, I had a look at I think the code looks like it should work. Can you please start adding this decorator to functions and we can see what happens with the tests. Thanks!

@Pradyumn-cloud
Copy link
Author

ok

@Pradyumn-cloud
Copy link
Author

I think there are two logging... I forgot to remove the existing manual. Let me do changes to fix it.

remove earlier logging method, remove logging from private methods and Added init_log=False to internal function calls to prevent nested logging
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.

2 participants