Skip to main content

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

pip install s3-log-handler

Usage

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

Metadata

Release files for s3-log-handler 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for s3-log-handler 0.1.3
File Size Uploaded Provenance
s3_log_handler-0.1.3.tar.gz 5.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for s3-log-handler 0.1.3
File Interpreter ABI Platform
s3_log_handler-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / s3_log_handler-0.1.3.tar.gz

Download URL s3_log_handler-0.1.3.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7e02059e9826b003d197562e0bcd74d0a44b3c3cf32ed89e630cad9d9caf5aef
BLAKE2b-256 checksum
How to use checksums
a756e81a749941cc5bb95a6550392d33334d1e9bef200a87a847ef4b071072ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/23.5.0

Release files / s3_log_handler-0.1.3-py3-none-any.whl

Download URL s3_log_handler-0.1.3-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
450e524ec53d5c5456a04537f635097aa9cdfd1065aa67884ee84b1f317c6055
BLAKE2b-256 checksum
How to use checksums
25886972ecbeb8f1cfbdd20bff46fb28c5d903d868517a97a92ddd0d64200213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/23.5.0

Security for s3-log-handler 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page