Skip to main content

Asynchronous logging with queueing and deduplication

Project description

aqdlog

aqdlog is a lightweight asynchronous logging helper for Python.

Features

  • Non-blocking logging via QueueHandler + QueueListener
  • Duplicate suppression for repeated (level, message) pairs
  • Optional file output with rotation modes:
    • none
    • size
    • time
  • Optional compression for rotated files:
    • .zst when zstd is available
    • .gz fallback when zstd is unavailable
  • Rotation retention via backup_count (0..10)
  • Graceful logger shutdown via logger.shutdown()

Installation

Using uv:

uv add aqdlog

Or with pip:

pip install aqdlog

Quick start

from aqdlog import logger

log = logger("my_app", level="INFO")
log.info("Service start")
log.warning("Low disk space")
log.warning("Low disk space")  # Duplicate suppressed
log.shutdown()

API

logger(
		name: str,
		level: str | int = "INFO",
		log_file: str | None = None,
		rotation: Literal["none", "size", "time"] = "none",
		max_bytes: int = 5_000_000,
		when: str = "H",
		interval: int = 1,
		backup_count: int = 5,
		compress: bool = False,
) -> logging.Logger

Parameters

  • name: Logger name (for example __name__)
  • level: Logging level as string or integer
  • log_file: Optional output file path; when omitted, logs go to console
  • rotation: Rotation strategy (none, size, time)
  • max_bytes: File size threshold for size rotation
  • when: Time unit for time rotation (passed to TimedRotatingFileHandler)
  • interval: Rotation interval for time rotation
  • backup_count: Number of rotated files to keep (0..10)
  • compress: Compress rotated files; requires log_file

Validation rules

  • compress=True requires log_file
  • backup_count must be between 0 and 10 (inclusive)
  • backup_count=0 disables rollover

Behavior notes

  • Duplicate suppression is based on (level, message) only.
  • Re-using the same logger name returns the same logger instance.
  • The returned logger includes a shutdown() method that stops the queue listener and closes handlers.

Examples

Run the included example script:

uv run python examples/example_script.py

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

aqdlog-2.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

aqdlog-2.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file aqdlog-2.0.0.tar.gz.

File metadata

  • Download URL: aqdlog-2.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aqdlog-2.0.0.tar.gz
Algorithm Hash digest
SHA256 145f2477886d6ecb5cbdeef25e9fe430b806a3d1c08b092b915198890c47a47a
MD5 52c757dfffdd7bc8d776fd2af85b2497
BLAKE2b-256 6cdcf9fc25fb5184508c73c8078122ae4339b111c4ad7549a9d7ddcbd48aa3b8

See more details on using hashes here.

File details

Details for the file aqdlog-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: aqdlog-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aqdlog-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c32a910c1458557b82149c15bc407a227ee4e18974a629d9441732c29883b36
MD5 3fcd9039b6d939cc6b000d47819eab00
BLAKE2b-256 4dbf92569f14ed9b3955b707e6d298505a7726bfbf6dbe298576b1fc51a1264a

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