Skip to content

refactor: replace print() calls with structured logging in verl daemon#530

Open
Alexi5000 wants to merge 2 commits into
microsoft:mainfrom
Alexi5000:pr/replace-debug-prints-with-logging
Open

refactor: replace print() calls with structured logging in verl daemon#530
Alexi5000 wants to merge 2 commits into
microsoft:mainfrom
Alexi5000:pr/replace-debug-prints-with-logging

Conversation

@Alexi5000

Copy link
Copy Markdown

Summary

  • Add import logging and module-level logger to agentlightning/verl/daemon.py
  • Replace 18 bare print() calls with structured logger calls at appropriate levels
  • Preserve print(..., 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 in agentlightning/logging.py.

Log level mapping

Category Level Examples
Server lifecycle info Proxy/server started, all tasks finished
Task progress info Completed N/M tasks
Data validation warning Missing triplets, unknown rollout IDs, null rewards
Errors error Setup failures, timeout errors
Verbose proxy debug Individual request proxying

Test plan

  • Existing tests pass — no behavior change beyond output destination
  • Log messages appear in configured log handlers instead of bare stdout
  • print(..., file=f) diagnostic logs still write to files correctly

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.
Copilot AI review requested due to automatic review settings May 21, 2026 22:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 logger and switched various status/warning/error messages from print() to logger.*.
  • 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.
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