Multiprocessing-safe domain-based logging framework with QueueListener architecture
Project description
repo = LoggingRepository(config)
queue = repo.get_queue()
Worker processes:
worker_repo = LoggingRepository(config, use_listener=False, queue=queue)
worker_repo.task.info("Worker started")
All processes log safely to the same listener and files.
Debug Control
Only .debug() messages are conditional via debug_enabled:
config.debug_enabled = False
repo.app.debug("Won't appear")
repo.app.info("Will appear")
Useful for toggling debug messages in production.
Output Structure
Logs are written in:
logs/
├─ app.log # domain logs
├─ db.log
├─ redis.log
├─ debug.log # per-level logs
├─ info.log
├─ warning.log
└─ error.log
Console output is colorized by level:
- DEBUG → blue
- INFO → green
- WARNING → yellow
- ERROR → red
Files remain clean.
Graceful Shutdown
The repository automatically shuts down on process exit and supports manual shutdown:
repo.shutdown()
Typical Usage Example
repo.app.info("Service starting")
try:
connect_db()
except Exception:
repo.db.exception("DB connection failed")
repo.redis.debug("Cache size: %d", cache_size)
Multiprocessing workers:
def worker(queue):
repo = LoggingRepository(config, use_listener=False, queue=queue)
repo.task.info("Worker task started")
Project Structure
miu_logger/
├─ repository.py # main LoggingRepository
├─ listener.py # QueueListener and handler setup
├─ logger_factory.py # logger creation functions
├─ conditional.py # ConditionalLogger
├─ filters.py # Logger filters
├─ formatters.py # ColoredFormatter
├─ config.py # LogConfig definition
└─ stubgen.py # stub generator for IDE autocomplete
When to Use
- Services with many subsystems
- Multiprocessing ingestion pipelines
- Long-running daemons
- Kubernetes / systemd services
- Need for clear operational logs
When Not to Use
- Single-file scripts
- No multiprocessing
- No domain separation required
Plain logging is sufficient in those cases.
License
MIT
Author
Bruno Miura
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
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 miu_logger-0.1.4.tar.gz.
File metadata
- Download URL: miu_logger-0.1.4.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
281d55857edd2fa715c2161a107bf81d5decf81dd6bbe6e8178012ea2683ac2d
|
|
| MD5 |
a7304cfd8cc3c5d4d11824e4618e2341
|
|
| BLAKE2b-256 |
a5b8ca2a7ad638e8cea473d456ae88e6b72b0953c8f065c61d28bbba5ac3a274
|
File details
Details for the file miu_logger-0.1.4-py3-none-any.whl.
File metadata
- Download URL: miu_logger-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eec995bd58a7e589fb180bcc674c7ac9a813b2ab4deee65a8d2db924a778ce9
|
|
| MD5 |
51174456d2c8d2fcea14a52d31ad83a2
|
|
| BLAKE2b-256 |
be950ca468f7461e4556cc0d34ea79c7c1e82bc96683fdd937c84f092fedcfa2
|