Skip to content

fix: Replace print statements with logging and logging modular level (PR2)#3648

Open
PredictiveManish wants to merge 4 commits intochaoss:mainfrom
PredictiveManish:libyear-util-update
Open

fix: Replace print statements with logging and logging modular level (PR2)#3648
PredictiveManish wants to merge 4 commits intochaoss:mainfrom
PredictiveManish:libyear-util-update

Conversation

@PredictiveManish
Copy link
Contributor

@PredictiveManish PredictiveManish commented Feb 5, 2026

Description
This PR standardizes the logging implementation across libyear_util to follow Python best practices and solve #3313:

Changes Made:

  1. Added module-level loggers: Each module now uses logger = logging.getLogger(__name__)
  2. Eliminated print statements: All console output now uses proper logging
  3. Fixed inconsistent patterns: Removed logger parameter passing in favor of module-level loggers
  4. Improved import organization: Removed duplicate imports

This PR partially solves #3313
Split of #3478
Notes for Reviewers

  • Consistent logging behavior across the codebase
  • Better control over log levels and output
  • Follows Python logging best practices
  • Easier debugging and monitoring
  • Cleaner separation of concerns

Testing

  • Enabled Python logging locally
  • Verified log messages emit via logger.info
  • No changes to control flow or task behavior
  • Verified logging output locally with logging.basicConfig(level=INFO).

Signed commits

  • Yes, I signed my commits.

Signed-off-by: PredictiveManish <manish.tiwari.09@zohomail.in>
Signed-off-by: PredictiveManish <manish.tiwari.09@zohomail.in>
Signed-off-by: PredictiveManish <manish.tiwari.09@zohomail.in>
@MoralCode
Copy link
Contributor

MoralCode commented Feb 5, 2026

This PR partially fixes #3313

Try not to put the word "fixes" right before the issue citation since thats what triggers github to link it to the underlying issue in a way that will close it when this merges.

its a tricky balance between citing the changes/connecting the issue and still having the multi-part changes work

Copy link
Contributor

@MoralCode MoralCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this PR does replace some prints with proper logger calls, It also introduces some less-than-ideal practices (especially global variables) that i think outweigh the benefit of the logs

Comment on lines -56 to +55
logging.debug(f"[{file_name}] Successfully decoded with encoding: {encoding}")
logger.debug(f"[{file_name}] Successfully decoded with encoding: {encoding}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more global variable logging that needs fixing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MoralCode : @ABrain7710 can set me straight if I am not understanding correctly, but our logging is designed to create logs that are distinct to the different data collection utilities/tasks Augur performs. This is one of those tasks. It would create much more object-creation overhead if a logger instance were instantiated in each method for this task. I am assuming that by global you mean global across methods in this file, which is for one task.

I think there may be a trade-off between the downside of all the methods in a task sharing a logger and the cost of creating and destroying logger objects in each method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my feedback here is sort of addressing that problem.

youre right that we dont want to create a logger per method. But i also dont want to be using a global variable that all our methods just... use because then the dependencies/expectations each method requires to run are not clearly laid out in the signature.

What I would like to see here is that, instead of getting a logger variable from global scope, the logger would be passed in as a parameter like we do in many other places. Then we can instantiate it when we set up the task and pass it to the entrypoint, which will pass it down through any other functions that get called.

This will also help us run tasks individually in isolated contexts, like unit testing, more easily.

@MoralCode MoralCode added the pending changes PRs that have review comments that have been added but havent been addressed in a while label Mar 5, 2026
Added logger parameter to get_release_date function.

Signed-off-by: Manish Tiwari <manish.tiwari.09@zohomail.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending changes PRs that have review comments that have been added but havent been addressed in a while

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants