pip install futurelog
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.
from futurelog import FutureLogger
future_logger = FutureLogger(__name__)
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")
logger.consume(topic)
Example:
future_logger.consume("server1")
future_logger.consume("server2")
FutureLogger.consume_all_logger_for(topic)
Example:
FutureLogger.consume_all_logger_for("server1")
FutureLogger.consume_all_logger_for("server2")
FutureLogger.consume_all_logger()