Skip to main content

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)
  • Optional silent mode to disable console fallback and parent/root propagation
  • 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,
		silent: 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
  • silent: Disable console fallback and stop propagation to parent/root loggers

Validation rules

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

File-only / journald-safe mode

Use silent=True when you want aqdlog to write only to its configured file handlers and not bubble records into parent or root loggers.

from aqdlog import logger

log = logger(
	"my_service",
	log_file="/var/log/my_service.log",
	rotation="size",
	max_bytes=5_000_000,
	backup_count=3,
	compress=True,
	silent=True,
)

log.info("This goes to the log file only")
log.shutdown()

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.
  • When silent=True, logger.propagate is set to False.

Examples

Run the included example script:

uv run python examples/example_script.py

License

MIT

Metadata

Release files for aqdlog 2.1.0

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

Source distribution (sdist)

Source distribution for aqdlog 2.1.0
File Size Uploaded
aqdlog-2.1.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aqdlog 2.1.0
File Interpreter ABI Platform
aqdlog-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / aqdlog-2.1.0.tar.gz

Download URL aqdlog-2.1.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
df9fea1991dfb593788a2a3659c01aa5f15ceac21f79dcf335a8c91b554c21db
BLAKE2b-256 checksum
How to use checksums
667ee02c1b9c1294bed5a6844b41263b4f4afa9d7e668d469a02eacfd9faa584
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / aqdlog-2.1.0-py3-none-any.whl

Download URL aqdlog-2.1.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7658bc75f9145faa3a6ba48a95f9b56f479d5667da847c9e07800a7d0e87ba4
BLAKE2b-256 checksum
How to use checksums
0bcf0f0dabd6b4bb31224829c22edbd3731415379341de228d9f553f60eb76c3
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

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