# S3 Log Handler
A Python logging handler that asynchronously uploads logs to Amazon S3 in batches.
## Features
- Asynchronous upload to S3 using aioboto3
- Batching of log messages for efficient uploading
- Automatic compression of logs using gzip
- Configurable batch size and flush intervals
- Thread-safe operation
- Graceful shutdown handling with proper cleanup
## Installation
```bash
pip install s3-log-handler
```
## Usage
```python
import logging
from s3_log_handler import S3LogHandler
# Configure AWS credentials
client_params = {
"aws_access_key_id": "your_access_key",
"aws_secret_access_key": "your_secret_key",
"region_name": "your_region"
}
# Create and configure the handler
handler = S3LogHandler(
client_params=client_params,
bucket_name="your-bucket-name",
log_prefix="application-logs",
batch_size=100,
flush_interval=300
)
# Add handler to logger
logger = logging.getLogger()
logger.addHandler(handler)
# Log messages will now be uploaded to S3
logger.info("Hello, S3!")
```
## Configuration
- `client_params`: Dictionary of AWS client parameters
- `bucket_name`: Name of the S3 bucket
- `log_prefix`: Prefix for S3 keys (default: "application-logs")
- `batch_size`: Number of logs to batch before upload (default: 100)
- `flush_interval`: Maximum seconds between uploads (default: 300)
## License
MIT License - see LICENSE file for details
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/s3-log-handler",
"name": "s3-log-handler",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "logging, s3, aws, handler, async",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/a7/56/e81a749941cc5bb95a6550392d33334d1e9bef200a87a847ef4b071072ce/s3_log_handler-0.1.3.tar.gz",
"platform": null,
"description": "# S3 Log Handler\n\nA Python logging handler that asynchronously uploads logs to Amazon S3 in batches.\n\n## Features\n\n- Asynchronous upload to S3 using aioboto3\n- Batching of log messages for efficient uploading\n- Automatic compression of logs using gzip\n- Configurable batch size and flush intervals\n- Thread-safe operation\n- Graceful shutdown handling with proper cleanup\n\n## Installation\n\n```bash\npip install s3-log-handler\n```\n\n## Usage\n\n```python\nimport logging\nfrom s3_log_handler import S3LogHandler\n\n# Configure AWS credentials\nclient_params = {\n \"aws_access_key_id\": \"your_access_key\",\n \"aws_secret_access_key\": \"your_secret_key\",\n \"region_name\": \"your_region\"\n}\n\n# Create and configure the handler\nhandler = S3LogHandler(\n client_params=client_params,\n bucket_name=\"your-bucket-name\",\n log_prefix=\"application-logs\",\n batch_size=100,\n flush_interval=300\n)\n\n# Add handler to logger\nlogger = logging.getLogger()\nlogger.addHandler(handler)\n\n# Log messages will now be uploaded to S3\nlogger.info(\"Hello, S3!\")\n```\n\n## Configuration\n\n- `client_params`: Dictionary of AWS client parameters\n- `bucket_name`: Name of the S3 bucket\n- `log_prefix`: Prefix for S3 keys (default: \"application-logs\")\n- `batch_size`: Number of logs to batch before upload (default: 100)\n- `flush_interval`: Maximum seconds between uploads (default: 300)\n\n## License\n\nMIT License - see LICENSE file for details\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python logging handler that uploads logs to Amazon S3",
"version": "0.1.3",
"project_urls": {
"Documentation": "https://github.com/yourusername/s3-log-handler#readme",
"Homepage": "https://github.com/yourusername/s3-log-handler",
"Repository": "https://github.com/yourusername/s3-log-handler"
},
"split_keywords": [
"logging",
" s3",
" aws",
" handler",
" async"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25886972ecbeb8f1cfbdd20bff46fb28c5d903d868517a97a92ddd0d64200213",
"md5": "a66e6a3d529fd49c0a18a2763b4ecc10",
"sha256": "450e524ec53d5c5456a04537f635097aa9cdfd1065aa67884ee84b1f317c6055"
},
"downloads": -1,
"filename": "s3_log_handler-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a66e6a3d529fd49c0a18a2763b4ecc10",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 5482,
"upload_time": "2024-11-03T07:05:44",
"upload_time_iso_8601": "2024-11-03T07:05:44.904771Z",
"url": "https://files.pythonhosted.org/packages/25/88/6972ecbeb8f1cfbdd20bff46fb28c5d903d868517a97a92ddd0d64200213/s3_log_handler-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a756e81a749941cc5bb95a6550392d33334d1e9bef200a87a847ef4b071072ce",
"md5": "7a2f696f1698e90d3357cb7952f2c953",
"sha256": "7e02059e9826b003d197562e0bcd74d0a44b3c3cf32ed89e630cad9d9caf5aef"
},
"downloads": -1,
"filename": "s3_log_handler-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "7a2f696f1698e90d3357cb7952f2c953",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 5240,
"upload_time": "2024-11-03T07:05:46",
"upload_time_iso_8601": "2024-11-03T07:05:46.304372Z",
"url": "https://files.pythonhosted.org/packages/a7/56/e81a749941cc5bb95a6550392d33334d1e9bef200a87a847ef4b071072ce/s3_log_handler-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-03 07:05:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "s3-log-handler",
"github_not_found": true,
"lcname": "s3-log-handler"
}