def send_back(): handler = MultiProcessingHandler(queue) handler.push_thread() try: logbook.warn(message) finally: handler.pop_thread()
def start_logging_in_process(queue): """ Start logging in multiprocessing process """ if queue is not None: mp_handler = MultiProcessingHandler(queue) mp_handler.push_application()
def __call__(self): from logbook.queues import MultiProcessingHandler handler = MultiProcessingHandler(self.queue) handler.push_thread() try: logbook.warn('Hello World') finally: handler.pop_thread()
def enable_multiprocess_log_handing(args): """ Set up logging when using multiprocessing """ normal_handler = log_handler(args, thread_wrapping=False) manager = multiprocessing.Manager() queue = manager.Queue(-1) mp_handler = MultiProcessingHandler(queue) mp_handler.push_application() mp_sub = MultiProcessingSubscriber(queue) mp_sub.dispatch_in_background(normal_handler) return queue
def setup_logging(queue: mp.Queue): logbook.set_datetime_format("local") handler = MultiProcessingHandler(queue) handler.push_application()
def __call__(self): from logbook.queues import MultiProcessingHandler with MultiProcessingHandler(self.queue): logbook.warn(self.message)