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:
nonesizetime
- Optional compression for rotated files:
.zstwhen zstd is available.gzfallback 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 integerlog_file: Optional output file path; when omitted, logs go to consolerotation: Rotation strategy (none,size,time)max_bytes: File size threshold forsizerotationwhen: Time unit fortimerotation (passed toTimedRotatingFileHandler)interval: Rotation interval fortimerotationbackup_count: Number of rotated files to keep (0..10)compress: Compress rotated files; requireslog_file
Validation rules
compress=Truerequireslog_filebackup_countmust be between0and10(inclusive)backup_count=0disables 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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
145f2477886d6ecb5cbdeef25e9fe430b806a3d1c08b092b915198890c47a47a
|
|
| MD5 |
52c757dfffdd7bc8d776fd2af85b2497
|
|
| BLAKE2b-256 |
6cdcf9fc25fb5184508c73c8078122ae4339b111c4ad7549a9d7ddcbd48aa3b8
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c32a910c1458557b82149c15bc407a227ee4e18974a629d9441732c29883b36
|
|
| MD5 |
3fcd9039b6d939cc6b000d47819eab00
|
|
| BLAKE2b-256 |
4dbf92569f14ed9b3955b707e6d298505a7726bfbf6dbe298576b1fc51a1264a
|