Skip to main content

Reusable CloudWatch log sender

Project description

logservice

An async Python module for sending structured JSON logs to AWS CloudWatch Logs from any Python application, including FastAPI, Flask, background workers, and CLI tools.


📦 Installation

Install directly from PyPI:

pip install logservice

🚀 Usage

from fastapi import FastAPI
from logservice import AsyncCloudWatchLogService, LogEntry

app = FastAPI()

log_service = AsyncCloudWatchLogService(
    aws_access_key="...",
    aws_secret_key="...",
    region_name="us-east-1",
    log_group_name="app-logs",
    log_stream_name="login-events"
)

@app.post("/login")
async def login():
    await log_service.log(LogEntry(
        level="INFO",
        message="User logged in",
        service_name="LoginService",
        extra={"user_id": 123}
    ))
    return {"message": "Logged"}

🔧 Development & Deployment

Prerequisites

pip install twine build

Deployment Steps

  1. Update version in setup.py
  2. Clean old builds:
    rm -rf dist/ build/ *.egg-info/
    
  3. Build package:
    python setup.py sdist bdist_wheel
    
  4. Upload to PyPI:
    twine upload dist/*
    

Quick Deploy Script

# Clean, build, and deploy
rm -rf dist/ build/ *.egg-info/
python setup.py sdist bdist_wheel
twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logservice-0.1.9.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logservice-0.1.9-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file logservice-0.1.9.tar.gz.

File metadata

  • Download URL: logservice-0.1.9.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for logservice-0.1.9.tar.gz
Algorithm Hash digest
SHA256 d41516bbc67f2ad268c8633daf09908821796ce9f9b838d6a0b16e31137ebd35
MD5 76052b73ba36db24c29e3b00f5371ff2
BLAKE2b-256 ff39af86c2ae5000ba8739250d216762d1325dfb16b67ece642f07d08ab209c6

See more details on using hashes here.

File details

Details for the file logservice-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: logservice-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for logservice-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6746980bd120f3a5fd9221c7b3f5d9314a7a7555a53e7fc52ce0915a42e92b33
MD5 1096e2367dc0fefe1a4247db548bd4b0
BLAKE2b-256 20c142816d79a04ed5f862766114fbba7844a9d63139de276ed684d502ea310a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page