in mico/utils/multiprocess_logging.py [0:0]
def setup_worker_logging(rank: int, log_queue: Queue):
"""
Method to initialize worker's logging in a distributed setup. The worker processes
always write their logs to the `log_queue`. Messages in this queue in turn gets picked
by parent's `QueueListener` and pushes them to respective file/stream log handlers.
Parameters
----------
rank : ``int``, required
Rank of the worker
log_queue : ``Queue``, required
The common log queue to which the workers
"""
queue_handler = QueueHandler(log_queue)
# Add a filter that modifies the message to put the
# rank in the log format
worker_filter = WorkerLogFilter(rank)
queue_handler.addFilter(worker_filter)
queue_handler.setLevel(logging.INFO)
root_logger = logging.getLogger()
root_logger.addHandler(queue_handler)
# Default logger level is WARNING, hence the change. Otherwise, any worker logs
# are not going to get bubbled up to the parent's logger handlers from where the
# actual logs are written to the output
root_logger.setLevel(logging.INFO)