Skip to content

Conversation

@rasdani
Copy link
Contributor

@rasdani rasdani commented Jan 13, 2026

Description

adds option to write logs to file by passing log_file to setup_logging

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes


Note

Logging enhancement

  • Extend vf.setup_logging(level="INFO", log_file: str | None = None) to accept log_file; when provided, use FileHandler else default to StreamHandler(stderr)
  • Update docs/reference.md to reflect new signature and behavior

Written by Cursor Bugbot for commit 8805864. This will update automatically on new commits. Configure here.

if log_file is not None:
handler = logging.FileHandler(log_file)
else:
handler = logging.StreamHandler(sys.stderr)
Copy link

Choose a reason for hiding this comment

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

FileHandler not closed before clearing handlers

Low Severity

When setup_logging is called multiple times with log_file specified, logger.handlers.clear() removes the old handler from the list without calling handler.close() first. With the previous StreamHandler(sys.stderr) this was benign since stderr is always open, but with the new FileHandler this leaks file descriptors. Each subsequent call leaves the previous log file handle open.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member

@mikasenghaas mikasenghaas left a comment

Choose a reason for hiding this comment

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

do you envision each env worker calling setup_logging with a diff logfile? if so, im wondering if this should not rather live in prime-rl because it seems quite prime-rl specific

also i think setup_logging is called upon import by vf iirc, so we would have multiple calls to this func (once upon import, and then once from the env worker to set it up). wondering if its not just easier to pipe process stdout/stderr to file but maybe missing smth


# Create a StreamHandler that writes to stderr
handler = logging.StreamHandler(sys.stderr)
# Create handler - file or stderr
Copy link
Member

Choose a reason for hiding this comment

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

should we not rather support console + file? ie. file logging is an add-on, not a replacement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then it defies the purpose of keeping orchestrator logs clean via files.
i would then just handle streams in prime-rl natively.
https://github.com/PrimeIntellect-ai/prime-rl/pull/1561/changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can also do

  vf.setup_logging(level=vf_log_level.upper())                                                                                                                                                                         
  # Redirect verifiers to file instead of inherited stderr                                                                                                                                                             
  vf_logger = logging.getLogger("verifiers")                                                                                                                                                                           
  vf_logger.handlers.clear()                                                                                                                                                                                           
  vf_logger.addHandler(logging.FileHandler(log_file))  

in prime-rl. thought it was cleaner to have it live in vf.

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.

3 participants