Consume logs by block in async application
Project description
Installation
pip install futurelog
Usage
Introduction
The goal of this library is to provide a way to defer logs and consume (print) them when needed, in an async application.
For instance, it would perfectly fit a config deployer in async. It would help to keep messages grouped by servers.
Usage should be limited to reporting and not error/exception logging. Also you should ensure you catch all possible exception in your program in your entrypoint, in order to consume all logs before exiting your application.
Create a logger
from futurelog import FutureLogger
future_logger = FutureLogger(__name__)
Register logs
The methods supported are: .debug()
, .info()
, .warning()
, .error()
, .critical()
future_logger.debug(topic, msg)
Example:
future_logger.debug("server1", "deploying stuff 1")
future_logger.error("server1", "failed")
future_logger.debug("server2", "deploying stuff 1")
future_logger.warning("server2", "success")
Consume logs
One specific logger
logger.consume(topic)
Example:
future_logger.consume("server1")
future_logger.consume("server2")
All loggers for a topic (one for each module)
FutureLogger.consume_all_logger_for(topic)
FutureLogger.consume_all_logger_for("server1")
FutureLogger.consume_all_logger_for("server2")
All unconsumed logger
FutureLogger.consume_all_logger()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file FutureLog-0.1.1.tar.gz
.
File metadata
- Download URL: FutureLog-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba627af2c7655c8412993b0b4bf3a34ca4eb3de7467e0c1cb4eab50033a1c634 |
|
MD5 | 540694aec7e3c69d1246413aaf4f494e |
|
BLAKE2b-256 | cebdc9ab7bb7afab8e5c0db54f8e54fd9d7ac8c4cda8c9b487057f8274739b26 |