Logging#147
Open
ParthShikhare19 wants to merge 2 commits into
Open
Conversation
ranahaani
approved these changes
Oct 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Implement Structured Logging for GNews
for the issue #135
Description
Replace print statements with proper structured logging using Python's logging module to provide better debugging capabilities, configurable log levels, and optional file logging for production environments.
Why This Change?
Better Debugging: Structured logging provides more context than print statements
Configurable Levels: Support for DEBUG, INFO, WARNING, ERROR, CRITICAL levels
Production Ready: Optional file logging and proper log formatting
Maintainability: Easier to control log output in different environments
Implementation Details
Features Added:
Configurable Logging: Added log_level and log_file parameters to GNews constructor
Enhanced Format: Improved log format with timestamp, logger name, level, and message
File Logging: Optional file output in addition to console logging
Proper Log Levels: Replaced print statements with appropriate logger calls (WARNING/ERROR)
Backward Compatibility:
All new parameters are optional with sensible defaults
Existing code continues to work without modification
No breaking changes to the public API
Files Modified
gnews/gnews.py: Added logging configuration and replaced print statements
tests/test_gnews.py: Added logging suppression for clean test output
README.md: Documented new logging parameters and usage examples
Testing
All existing tests pass
Logging output is suppressed during testing
Verified functionality with different log levels and file output
Usage Examples