[misc] chore: Migrate print statements to logging for better observability#5213
[misc] chore: Migrate print statements to logging for better observability#5213fjosw wants to merge 1 commit intoverl-project:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request is a large-scale refactoring that migrates over 650 print statements to structured logging using Python's logging module. The changes include standardizing logger initialization to use logging.getLogger(__name__), replacing print calls with appropriate logger methods (.info, .debug, .warning, .error), and changing the default logging level from WARN to INFO for better observability. I have reviewed the changes across the numerous affected files and found them to be consistent, well-executed, and a significant improvement to the codebase's maintainability and debuggability. The code now follows standard Python logging best practices. I did not find any high or critical issues with this refactoring.
What does this PR do?
This PR introduces proper Python logging throughout the verl codebase, replacing ~650+ print statements with structured logging calls. This improves observability, enables log level filtering, and follows Python best practices. This is a surgical change but affects a lot of files.
Key changes:
Test
This is a refactoring change that doesn't alter runtime behavior. The logging output can be controlled via the standard Python logging configuration or environment variables like VERL_LOGGING_LEVEL.
API and Usage Example
Control log verbosity via environment variable
export VERL_LOGGING_LEVEL=DEBUG# Show all logsexport VERL_LOGGING_LEVEL=INFO# Show info and above (default for most use cases)export VERL_LOGGING_LEVEL=WARNING# Quieter outputOr configure programmatically
Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace. (If not accessible, please try the Feishu group (飞书群).)recipesubmodule, please also update the reference to the submodule commit viagit submodule update --remoteorcd recipe && git pull origin main.