# SkypoukLogger
A customized rotational logger that prints logs to console and stores them in monthly log files with automatic archiving and compression.
## Features
- **Dual Output**: Logs to both console and file simultaneously
- **Monthly Rotation**: Creates monthly log files (format: `logs_MM_YYYY.log`)
- **Size-based Rotation**: Automatically rotates files when they reach 512 MB
- **Automatic Archiving**: At the start of each month, previous month's logs are merged and compressed into `.gz` files
- **Clean Management**: Removes original files after successful archiving
- **Type Safety**: Full type hints for better IDE support and code reliability
- **Exception Handling**: Custom exceptions for better error management
## Installation
```bash
pip install date-aware-logger
```
## Quick Start
```python
from dateawarelogger import SkypoukLogger
# Initialize the logger
logger = SkypoukLogger()
# Log messages at different levels
logger.info("Application started")
logger.debug("Debug information")
logger.warning("This is a warning")
logger.error("An error occurred")
logger.critical("Critical system failure")
```
## Advanced Usage
### Custom Log Directory
```python
from dateawarelogger import SkypoukLogger
# Use a custom directory for logs
logger = SkypoukLogger(log_directory="custom_logs")
logger.info("Logging to custom directory")
```
### Error Handling
```python
from dateawarelogger import SkypoukLogger, SkypoukLoggerError
try:
logger = SkypoukLogger()
logger.info("This works fine")
except SkypoukLoggerError as e:
print(f"Logger error: {e}")
if e.original_exception:
print(f"Original cause: {e.original_exception}")
```
## How It Works
### File Structure
The logger creates the following structure:
```
logs/
├── logs_01_2024.log # Current month's log file
├── logs_01_2024.log.1 # Rotated file (when size limit reached)
├── logs_12_2023.log.gz # Previous month's compressed archive
└── logs_11_2023.log.gz # Earlier month's compressed archive
```
### Rotation Logic
1. **Size-based Rotation**: When a log file reaches 512 MB, it's rotated (renamed with `.1`, `.2`, etc. suffix)
2. **Monthly Archiving**: At the start of each month:
- All log files from the previous month are merged
- The merged file is compressed into a `.gz` archive
- Original uncompressed files are removed
3. **Backup Count**: Maintains up to 10 rotated files per month
### Log Format
Each log entry follows this format:
```
2024-01-15 10:30:45,123 - INFO - Your log message here
2024-01-15 10:30:46,124 - ERROR - Error message here
```
## API Reference
### SkypoukLogger
#### `__init__(log_directory: str = "logs")`
Initialize the logger.
**Parameters:**
- `log_directory` (str): Directory where log files will be stored. Defaults to "logs".
#### Logging Methods
- `debug(message: str)`: Log a debug message
- `info(message: str)`: Log an info message
- `warning(message: str)`: Log a warning message
- `error(message: str)`: Log an error message
- `critical(message: str)`: Log a critical message
### SkypoukLoggerError
Custom exception class for logger-related errors.
**Attributes:**
- `original_exception`: The original exception that caused this error (if any)
## Requirements
- Python 3.7+
- No external dependencies (uses only Python standard library)
## Development
### Setting up Development Environment
```bash
# Clone the repository
git clone https://github.com/Skypouk/Rotational-Monthly-Logger.git
cd skypouk-logger
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with dev dependencies
pip install -e ".[dev]"
```
### Running Tests
```bash
# Run tests
pytest
# Run tests with coverage
pytest --cov=dateawarelogger --cov-report=html
```
### Code Quality
```bash
# Format code
black dateawarelogger tests
# Lint code
flake8 dateawarelogger tests
# Type checking
mypy dateawarelogger
```
## Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Add tests for your changes
5. Ensure all tests pass and code is properly formatted
6. Commit your changes (`git commit -m 'Add amazing feature'`)
7. Push to the branch (`git push origin feature/amazing-feature`)
8. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Changelog
### v1.1.0
- Initial release
- Basic rotational logging functionality
- Monthly archiving and compression
- Console and file output
- Type hints and comprehensive documentation
## Support
If you encounter any issues or have questions, please [open an issue](https://github.com/Skypouk/Rotational-Monthly-Logger.git/issues) on GitHub.
Raw data
{
"_id": null,
"home_page": null,
"name": "date-aware-logger",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "logging, logger, rotation, archiving, compression",
"author": null,
"author_email": "Achraf Bentaher <achraf.bentaher.ing@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/99/5d/3d8eff8c3ebd42c3e97a2f8f00284171e51e13445cbef634d49fee8950e1/date_aware_logger-1.1.0.tar.gz",
"platform": null,
"description": "# SkypoukLogger\n\nA customized rotational logger that prints logs to console and stores them in monthly log files with automatic archiving and compression.\n\n## Features\n\n- **Dual Output**: Logs to both console and file simultaneously\n- **Monthly Rotation**: Creates monthly log files (format: `logs_MM_YYYY.log`)\n- **Size-based Rotation**: Automatically rotates files when they reach 512 MB\n- **Automatic Archiving**: At the start of each month, previous month's logs are merged and compressed into `.gz` files\n- **Clean Management**: Removes original files after successful archiving\n- **Type Safety**: Full type hints for better IDE support and code reliability\n- **Exception Handling**: Custom exceptions for better error management\n\n## Installation\n\n```bash\npip install date-aware-logger\n```\n\n## Quick Start\n\n```python\nfrom dateawarelogger import SkypoukLogger\n\n# Initialize the logger\nlogger = SkypoukLogger()\n\n# Log messages at different levels\nlogger.info(\"Application started\")\nlogger.debug(\"Debug information\")\nlogger.warning(\"This is a warning\")\nlogger.error(\"An error occurred\")\nlogger.critical(\"Critical system failure\")\n```\n\n## Advanced Usage\n\n### Custom Log Directory\n\n```python\nfrom dateawarelogger import SkypoukLogger\n\n# Use a custom directory for logs\nlogger = SkypoukLogger(log_directory=\"custom_logs\")\nlogger.info(\"Logging to custom directory\")\n```\n\n### Error Handling\n\n```python\nfrom dateawarelogger import SkypoukLogger, SkypoukLoggerError\n\ntry:\n logger = SkypoukLogger()\n logger.info(\"This works fine\")\nexcept SkypoukLoggerError as e:\n print(f\"Logger error: {e}\")\n if e.original_exception:\n print(f\"Original cause: {e.original_exception}\")\n```\n\n## How It Works\n\n### File Structure\n\nThe logger creates the following structure:\n\n```\nlogs/\n\u251c\u2500\u2500 logs_01_2024.log # Current month's log file\n\u251c\u2500\u2500 logs_01_2024.log.1 # Rotated file (when size limit reached)\n\u251c\u2500\u2500 logs_12_2023.log.gz # Previous month's compressed archive\n\u2514\u2500\u2500 logs_11_2023.log.gz # Earlier month's compressed archive\n```\n\n### Rotation Logic\n\n1. **Size-based Rotation**: When a log file reaches 512 MB, it's rotated (renamed with `.1`, `.2`, etc. suffix)\n2. **Monthly Archiving**: At the start of each month:\n - All log files from the previous month are merged\n - The merged file is compressed into a `.gz` archive\n - Original uncompressed files are removed\n3. **Backup Count**: Maintains up to 10 rotated files per month\n\n### Log Format\n\nEach log entry follows this format:\n```\n2024-01-15 10:30:45,123 - INFO - Your log message here\n2024-01-15 10:30:46,124 - ERROR - Error message here\n```\n\n## API Reference\n\n### SkypoukLogger\n\n#### `__init__(log_directory: str = \"logs\")`\n\nInitialize the logger.\n\n**Parameters:**\n- `log_directory` (str): Directory where log files will be stored. Defaults to \"logs\".\n\n#### Logging Methods\n\n- `debug(message: str)`: Log a debug message\n- `info(message: str)`: Log an info message\n- `warning(message: str)`: Log a warning message\n- `error(message: str)`: Log an error message\n- `critical(message: str)`: Log a critical message\n\n### SkypoukLoggerError\n\nCustom exception class for logger-related errors.\n\n**Attributes:**\n- `original_exception`: The original exception that caused this error (if any)\n\n## Requirements\n\n- Python 3.7+\n- No external dependencies (uses only Python standard library)\n\n## Development\n\n### Setting up Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/Skypouk/Rotational-Monthly-Logger.git\ncd skypouk-logger\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\n\n# Install in development mode with dev dependencies\npip install -e \".[dev]\"\n```\n\n### Running Tests\n\n```bash\n# Run tests\npytest\n\n# Run tests with coverage\npytest --cov=dateawarelogger --cov-report=html\n```\n\n### Code Quality\n\n```bash\n# Format code\nblack dateawarelogger tests\n\n# Lint code\nflake8 dateawarelogger tests\n\n# Type checking\nmypy dateawarelogger\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Add tests for your changes\n5. Ensure all tests pass and code is properly formatted\n6. Commit your changes (`git commit -m 'Add amazing feature'`)\n7. Push to the branch (`git push origin feature/amazing-feature`)\n8. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Changelog\n\n### v1.1.0\n- Initial release\n- Basic rotational logging functionality\n- Monthly archiving and compression\n- Console and file output\n- Type hints and comprehensive documentation\n\n## Support\n\nIf you encounter any issues or have questions, please [open an issue](https://github.com/Skypouk/Rotational-Monthly-Logger.git/issues) on GitHub.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A customized rotational logger with monthly archiving and compression",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/Skypouk/Rotational-Monthly-Logger",
"Issues": "https://github.com/Skypouk/Rotational-Monthly-Logger.git/issues",
"Repository": "https://github.com/Skypouk/Rotational-Monthly-Logger.git"
},
"split_keywords": [
"logging",
" logger",
" rotation",
" archiving",
" compression"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "87ca2357d6677ec68a39921ae65b0ab0940f51e662d3156dd2264cf0a62862bf",
"md5": "eb8f0ab19a89e60157bebe971b75307c",
"sha256": "3c7b1cf3adf453029529ca5ae776d5ccee8438f3df1f231d09447c293e709994"
},
"downloads": -1,
"filename": "date_aware_logger-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb8f0ab19a89e60157bebe971b75307c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7523,
"upload_time": "2025-07-26T16:54:02",
"upload_time_iso_8601": "2025-07-26T16:54:02.946927Z",
"url": "https://files.pythonhosted.org/packages/87/ca/2357d6677ec68a39921ae65b0ab0940f51e662d3156dd2264cf0a62862bf/date_aware_logger-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "995d3d8eff8c3ebd42c3e97a2f8f00284171e51e13445cbef634d49fee8950e1",
"md5": "180850db7804789700470ef8d8c40af2",
"sha256": "169e7d8c9068e7f4fd6efe6dd82e96ba9fe7712ba62f04552046a7a949d8379d"
},
"downloads": -1,
"filename": "date_aware_logger-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "180850db7804789700470ef8d8c40af2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8591,
"upload_time": "2025-07-26T16:54:04",
"upload_time_iso_8601": "2025-07-26T16:54:04.192117Z",
"url": "https://files.pythonhosted.org/packages/99/5d/3d8eff8c3ebd42c3e97a2f8f00284171e51e13445cbef634d49fee8950e1/date_aware_logger-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-26 16:54:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Skypouk",
"github_project": "Rotational-Monthly-Logger",
"github_not_found": true,
"lcname": "date-aware-logger"
}