Refactor logging to use in-memory buffer instead of file.#961
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the logging mechanism by replacing file-based logging with an in-memory buffer that logs to both the console and memory.
- Replaces file logging with a StringIO-based memory buffer
- Updates cleanup and upload functions to clear and use the in-memory log content
Comments suppressed due to low confidence (2)
agentops/logging/instrument_logging.py:18
- [nitpick] The variable 'file_logger' is misleading in the context of in-memory logging. Consider renaming it to 'in_memory_logger' for better clarity.
file_logger = logging.getLogger('agentops_file_logger')
agentops/logging/instrument_logging.py:4
- The 'atexit' module is imported but not used. Remove this unused import to clean up the code.
import atexit
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the logging functionality to use an in-memory buffer instead of a file, updating both the logging setup and cleanup mechanisms, and modifying the log upload process.
- Switch from file-based logging to an in-memory buffer
- Update cleanup to clear the in-memory buffer and restore the original print function
- Modify log upload to read and then clear the buffer content
…riginal print function is only replaced once.
bboynton97
left a comment
There was a problem hiding this comment.
i want to test on my machine today but the code looks good
|
tests need updated to account for the new logging method |
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
📥 Pull Request
📘 Description
Update print logger to log to buffer and console, and modify cleanup and upload functions to handle buffer content.
🧪 Testing
Describe the tests you performed to validate your changes.