-
Notifications
You must be signed in to change notification settings - Fork 472
add option for log_file to setup_logging
#723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ def setup_logging( | |
| level: str = "INFO", | ||
| log_format: Optional[str] = None, | ||
| date_format: Optional[str] = None, | ||
| log_file: Optional[str] = None, | ||
| ) -> None: | ||
| """ | ||
| Setup basic logging configuration for the verifiers package. | ||
|
|
@@ -51,14 +52,18 @@ def setup_logging( | |
| level: The logging level to use. Defaults to "INFO". | ||
| log_format: Custom log format string. If None, uses default format. | ||
| date_format: Custom date format string. If None, uses default format. | ||
| log_file: Path to log file. If None, logs to stderr. | ||
| """ | ||
| if log_format is None: | ||
| log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" | ||
| if date_format is None: | ||
| date_format = "%Y-%m-%d %H:%M:%S" | ||
|
|
||
| # Create a StreamHandler that writes to stderr | ||
| handler = logging.StreamHandler(sys.stderr) | ||
| # Create handler - file or stderr | ||
| if log_file is not None: | ||
| handler = logging.FileHandler(log_file) | ||
| else: | ||
| handler = logging.StreamHandler(sys.stderr) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FileHandler not closed before clearing handlersLow Severity When Additional Locations (1) |
||
| handler.setFormatter(logging.Formatter(fmt=log_format, datefmt=date_format)) | ||
|
|
||
| # Get the root logger for the verifiers package | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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-rlnatively.https://github.com/PrimeIntellect-ai/prime-rl/pull/1561/changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can also do
in
prime-rl. thought it was cleaner to have it live invf.