refactor: replace print() calls with structured logging in verl daemon#530
refactor: replace print() calls with structured logging in verl daemon#530Alexi5000 wants to merge 1 commit 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.
|
@Alexi5000 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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.
| 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 |
| 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) |
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