refactor: replace print() calls with structured logging in verl daemon#530
Open
Alexi5000 wants to merge 2 commits into
Open
refactor: replace print() calls with structured logging in verl daemon#530Alexi5000 wants to merge 2 commits into
Alexi5000 wants to merge 2 commits into
Conversation
Replace 18 bare `print()` calls in `agentlightning/verl/daemon.py` with proper `logging` module calls at appropriate levels: - `logger.info()` for operational messages (server started, tasks complete) - `logger.warning()` for data validation issues (missing triplets, unknown IDs) - `logger.error()` for failures (setup errors, timeout errors) - `logger.debug()` for verbose proxy request logging This enables log filtering, formatting, and integration with the existing logging infrastructure configured in `agentlightning/logging.py`. Print-to-file calls (diagnostic mismatch logs) are left unchanged.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR replaces direct print() statements with structured logging to improve observability and control over output verbosity.
Changes:
- Introduced a module-level
loggerand switched various status/warning/error messages fromprint()tologger.*. - Updated proxy request logging to use parameterized logging instead of string interpolation.
- Standardized runtime progress/status output (server startup, task completion) via
logger.info/warning/error.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
390
to
394
| current_time = time.time() | ||
| num_requests += 1 | ||
| if current_time - last_request_time > 60 or num_requests == 1 or num_requests % 100 == 0: | ||
| print(f"Proxying {request.method} request to {target_server}. Request data: {request.get_data()}") | ||
| logger.debug("Proxying %s request to %s. Request data: %s", request.method, target_server, request.get_data()) | ||
| last_request_time = current_time |
Comment on lines
607
to
611
| try: | ||
| future.result(timeout=300) # Wait for completion with a timeout | ||
| except Exception as e: | ||
| print(f"Failed to set up data on server: {e}") | ||
| logger.error("Failed to set up data on server: %s", e) | ||
| raise |
| future.result() # Wait indefinitely for all tasks to complete | ||
| except Exception as e: | ||
| print(f"Error while waiting for tasks to finish: {e}") | ||
| logger.error("Error while waiting for tasks to finish: %s", e) |
Move logger = getLogger(__name__) below the full import block so it no longer splits stdlib and third-party imports (was failing isort --check-only in CI). Run isort and black over the file to format the new logging calls to the 120-char line length.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
import loggingand module-levelloggertoagentlightning/verl/daemon.pyprint()calls with structuredloggercalls at appropriate levelsprint(..., file=f)calls that write diagnostic logs to files (intentional I/O)Motivation
The verl daemon module uses bare
print()for all runtime messages — server startup, task progress, data validation warnings, and error reporting. This makes it impossible to filter, format, or route these messages through the logging infrastructure already configured inagentlightning/logging.py.Log level mapping
infoinfowarningerrordebugTest plan
print(..., file=f)diagnostic logs still write to files correctly