Skip to main content

Python client for audit logging services

Project description

Audit Log Client

Python client for interacting with audit logging services, supporting both synchronous and asynchronous usage.

Features

  • Dual Mode: Sync and Async APIs
  • Buffering: Configurable memory buffering
  • Retry Mechanism: Exponential backoff retries
  • Fallback Strategy: Local file storage on failure
  • Query Support: Flexible log querying capabilities

Installation

pip install audit-log-client

Quick Start

Synchronous Client

from audit_log_client import SyncAuditLogClient, AuditLog, AuditAction, AuditTarget

client = SyncAuditLogClient(
    base_url="http://audit.service/api",
    api_key="your-api-key"
)

log = AuditLog(
    action=AuditAction.UPDATE,
    target_type=AuditTarget.USER,
    user_id="admin",
    description="User profile updated",
    before={"name": "John"},
    after={"name": "John Doe"}
)

client.log(log)
client.close()

Asynchronous Client

import asyncio
from audit_log_client import AsyncAuditLogClient, AuditLog, AuditAction, AuditTarget

async def main():
    client = AsyncAuditLogClient(
        base_url="http://audit.service/api",
        api_key="your-api-key"
    )
    await client.initialize()
    
    log = AuditLog(
        action=AuditAction.CREATE,
        target_type=AuditTarget.ORDER,
        user_id="sales",
        description="New order created"
    )
    
    await client.log(log)
    await client.shutdown()

asyncio.run(main())

Documentation

Full documentation available at GitHub Wiki

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

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

audit_log_client-1.4.7.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

audit_log_client-1.4.7-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file audit_log_client-1.4.7.tar.gz.

File metadata

  • Download URL: audit_log_client-1.4.7.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for audit_log_client-1.4.7.tar.gz
Algorithm Hash digest
SHA256 70c1cff57ad938fb255f43f41b2f3d584d55d0640e406df78fa7c0873a56bbd9
MD5 10e3b0000fd322596792e1d0f2ee3fe4
BLAKE2b-256 1d8fc1edab72dd8cfdbd8b400dfe5f10d64768f8cf133a418fa60dc12782a23f

See more details on using hashes here.

File details

Details for the file audit_log_client-1.4.7-py3-none-any.whl.

File metadata

File hashes

Hashes for audit_log_client-1.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 25a1df502017f8e0b7b45d2d1b248d0bad762b37a2d9eb8d9e7eb1e818dbb5b4
MD5 49ca740c0b074a61229fdc722a798092
BLAKE2b-256 f16807ddf1828821d13218a04a0f844a25f7d5f8b9804b83bfd2f92b7bdd3b33

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