Skip to main content

A versatile logging package with async support

Project description

ai_logstash

A versatile logging package that supports both synchronous and asynchronous logging in Python, with Logstash integration for centralized log management and monitoring.

Features

  • Supports both synchronous and asynchronous logging
  • Integrates seamlessly with Logstash
  • Masks sensitive information automatically
  • Provides decorators for automatic exception logging
  • Includes environment variables and local variables in logs
  • Compatible with various Python applications, including FastAPI and Aiogram

Installation

Using pipenv (recommended)

[packages]
pipenv install ai_logstash

Using pip

pip install ai_logstash

Usage

Synchronous Logging

from ai_logstash import SyncAiLogger, sync_log_exception

logger = SyncAiLogger(
    'my-service',
    project_name="work_wallet",
    masked_variables_names=["PRIVATE", "password", "api_key"],
    logstash_host="logstash.example.com",
    logstash_port=5000,
    container_tag="1.0",
    environment="production"
)

@sync_log_exception(logger)
def my_function():
    logger.info("Starting my_function")
    # Your code here

Asynchronous Logging (e.g., for FastAPI or Aiogram)

from ai_logstash import AsyncAiLogger, create_async_error_handler

logger = AsyncAiLogger(
    'my-async-service',
    project_name="work_wallet",
    masked_variables_names=["PRIVATE", "password", "api_key"],
    logstash_host="logstash.example.com",
    logstash_port=5000,
    container_tag="1.0",
    environment="production"
)

errors_handler = create_async_error_handler(logger)

@errors_handler
async def my_async_function():
    await logger.info("Starting my_async_function")
    # Your async code here

Configuration

  • service_name: Name of your service
  • project_name: Name of your project (work_wallet, payout_bot, etc.)
  • masked_variables_names: List of sensitive variable names to be masked
  • logstash_host: Hostname of your Logstash server
  • logstash_port: Port of your Logstash server
  • container_tag: Tag for container version
  • environment: Deployment environment (e.g., "production", "development")
  • log_level: Logging level (default: "INFO")

Benefits

  • Centralized logging with Logstash integration
  • Automatic masking of sensitive information
  • Easy integration with various Python frameworks
  • Supports both synchronous and asynchronous applications
  • Includes detailed error information and environment variables

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

ai_logstash-0.7.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

ai_logstash-0.7.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file ai_logstash-0.7.0.tar.gz.

File metadata

  • Download URL: ai_logstash-0.7.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for ai_logstash-0.7.0.tar.gz
Algorithm Hash digest
SHA256 bcc39e071517fb557e559dc797f1ffae6c7c2bdc6d0ef85539926e454fe87f57
MD5 212e72b1ed3eb12b8193d3f2b19993d9
BLAKE2b-256 87c1eacf46fef1acb05d129cfb147c13b084559a62a83759546eb3b26a9a27bc

See more details on using hashes here.

File details

Details for the file ai_logstash-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: ai_logstash-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for ai_logstash-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7c9ac62453aaca8e78706b67542842652a90f2d798de51f9fac14e59a04bf5c
MD5 4b9ca19b8e1d309a5ab87ff7c8a0b976
BLAKE2b-256 da4bcb1ee8e1cc715d49d8ce61dfa0eefaef17b21a1aca8fe683d9ddfd18bb08

See more details on using hashes here.

Supported by

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