Contributing
Thank you for considering contributing to RichColorLog!
Getting Started
Fork the repository on GitHub
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/richcolorlog.git cd richcolorlog
Create a virtual environment:
python -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows
Install development dependencies:
pip install -e ".[dev]"
Development Setup
Install all optional dependencies for full testing:
pip install -e ".[all,dev]"
This includes:
rich- Rich librarypygments- Syntax highlightingpika- RabbitMQkafka-python- Kafkapyzmq- ZeroMQpsycopg2-binary- PostgreSQLmysql-connector-python- MySQLpytest- Testingsphinx- Documentation
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=richcolorlog
# Run specific test
pytest tests/test_logger.py -v
# Run the built-in test
python -c "from richcolorlog import test; test()"
Code Style
We use the following style guidelines:
PEP 8 for Python code style
Black for code formatting (optional)
Type hints where practical
Docstrings for public APIs
# Format code (optional)
black richcolorlog/
# Check style
flake8 richcolorlog/
Making Changes
Create a branch for your changes:
git checkout -b feature/my-new-feature
Make your changes and add tests
Run the tests to ensure nothing is broken:
pytest
Commit your changes:
git add . git commit -m "Add: description of changes"
Push to your fork:
git push origin feature/my-new-feature
Create a Pull Request on GitHub
Commit Messages
Use clear, descriptive commit messages:
Add:New featuresFix:Bug fixesUpdate:Changes to existing functionalityDocs:Documentation changesTest:Test additions/changesRefactor:Code refactoring
Example:
Add: Support for Redis handler
- Implement RedisHandler class
- Add configuration parameters to setup_logging
- Add tests for Redis functionality
- Update documentation
Pull Request Guidelines
Include tests for new functionality
Update documentation for API changes
Keep changes focused and atomic
Write clear PR descriptions
Reference related issues
Reporting Issues
When reporting issues, please include:
Python version
Operating system
RichColorLog version
Minimal code to reproduce the issue
Full traceback if applicable
Example issue report:
**Environment:**
- Python: 3.11.0
- OS: Ubuntu 22.04
- RichColorLog: 1.0.0
**Description:**
The logger crashes when using the RabbitMQ handler with...
**Code to reproduce:**
```python
from richcolorlog import setup_logging
logger = setup_logging(rabbitmq=True, ...)
```
**Traceback:**
```
Traceback (most recent call last):
...
```
Documentation
Build documentation locally:
cd docs
pip install -r requirements.txt
make html
# View in browser
open _build/html/index.html # macOS
xdg-open _build/html/index.html # Linux
Adding New Features
When adding new features:
Discuss in an issue first for major changes
Add type hints to function signatures
Add docstrings following Google style
Add tests with good coverage
Update relevant documentation
Add changelog entry
Example new handler:
class MyNewHandler(logging.Handler):
"""
Handler for sending logs to MyService.
Args:
host: Service hostname.
port: Service port.
level: Minimum logging level.
Example:
>>> handler = MyNewHandler(host='localhost', port=9999)
>>> logger.addHandler(handler)
"""
def __init__(self, host='localhost', port=9999, level=logging.DEBUG):
super().__init__(level)
self.host = host
self.port = port
self._connect()
def _connect(self):
"""Establish connection to service."""
pass
def emit(self, record):
"""Send log record to service."""
pass
def close(self):
"""Close connection."""
pass
Code of Conduct
Be respectful and inclusive
Focus on constructive feedback
Help others learn and grow
Keep discussions professional
Questions?
Open an issue on GitHub
Email: cumulus13@gmail.com
License
By contributing, you agree that your contributions will be licensed under the MIT License.