Add optional per-run log capture with optimized memory buffering for debugging and auditing#1085
Add optional per-run log capture with optimized memory buffering for debugging and auditing#1085
Conversation
Co-authored-by: DrewThomasson <126999465+DrewThomasson@users.noreply.github.com>
|
try to create a class file for every new feature like that so it will be easier to merge functions.py |
|
try to create a class file for every new feature like that so it will be easier to merge functions.py |
Co-authored-by: DrewThomasson <126999465+DrewThomasson@users.noreply.github.com>
Implemented memory buffering optimization in commit 37f714f and the latest update. The RunLogger now uses a 128KB buffer for log file writes, which significantly reduces disk I/O overhead:
This approach minimizes disk I/O while maintaining all functionality and ensuring no data loss. |
|
@copilot /Users/drew/ebook2audiobook/python_env/lib/python3.12/site-packages/iso639/iso639.py:20: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. |
... This warning is from the The RunLogger implementation doesn't import or use To suppress this specific warning if desired, you could add to the top of import warnings
warnings.filterwarnings('ignore', category=UserWarning, module='iso639')However, this is a separate issue from the logging feature and would affect the entire application, not just when RunLogger is active. |
|
yeah all of this warnings are not fatal. will be removed in next update |
|
@copilot |
|
@copilot |
Summary
Implements optional per-run log capture that saves all stdout/stderr output to log files for debugging and support purposes, without changing what users see in the terminal or Gradio UI. Features optimized memory buffering to minimize disk I/O overhead.
Problem
When users encounter issues during ebook-to-audiobook conversion, troubleshooting is difficult because:
Solution
This PR adds a new
RunLoggerclass that transparently captures all console output to timestamped log files while preserving the exact user experience. The feature is:process_dir/logs/when available, falling back to top-levellogs/Implementation Details
New Files
lib/classes/run_logger.pyRunLoggerclass - Main logging coordinator with memory bufferingTeeStreamclass - Writes to both terminal and log file with optimized bufferingModified Files
lib/conf.pylib/functions.pyRunLoggerintoconvert_ebook()function.gitignorelogs/directory and*.logfiles from repositoryLog File Format
Files are named:
run_YYYYMMDD-HHMMSS_<session_id>.logExample:
run_20251013-153915_ba800d22-ee51-11ef-ac34-d4ae52cfd9ce.logContents include:
Configuration
Users can customize behavior in
lib/conf.py:Performance Optimization
The
RunLoggeruses memory buffering to minimize disk I/O overhead:This ensures the logging feature has negligible performance impact even during conversions with high output volume.
Testing
All tests pass successfully:
Benefits
Backward Compatibility
--ebook) and batch (--ebooks_dir) conversionsThis pull request was created as a result of the following prompt from Copilot chat.
Original prompt
Summary
Implement optional per-run log capture that saves everything printed to stdout/stderr into a log file per generation attempt, without changing what the user sees in the terminal/Gradio UI. Provide a global toggle and basic retention. Follow existing project structure and conventions.
Requirements
Design (minimal and aligned to current structure)
Configuration in lib/conf.py
Extend lib/classes/redirect_console.py
New file lib/classes/log_manager.py
Wire into the session lifecycle in lib/functions.py
Documentation
Acceptance criteria
Implementation notes
Answer to “When is a log created, how are they named, how do they function?” for PR description
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.