Esempio n. 1
0
    def caplog(_caplog):
        class PropogateHandler(logging.Handler):
            def emit(self, record):
                logging.getLogger(record.name).handle(record)

        from loguru import logger
        from pypads.pads_loguru import logger_manager
        handler_id = logger_manager.add(PropogateHandler(), format="{message}")
        yield _caplog
        logger_manager.remove(handler_id)
Esempio n. 2
0
    def finalize_output(pads, logger_call, output, *args, **kwargs):
        logs = pads.cache.run_get("loguru_logger")
        lid = pads.cache.run_get("loguru_logger_lid")
        folder = get_temp_folder()
        try:
            from pypads.pads_loguru import logger_manager
            logger_manager.remove(lid)
        except Exception:
            pass

        import glob
        for file in glob.glob(os.path.join(folder, "run_*.log")):
            pads.api.log_artifact(file, description="Logs of the current run", artifact_path=logs.path)

        output.logs = logs.store()
Esempio n. 3
0
 def remove_default_logger(self):
     from pypads.pads_loguru import logger_manager
     logger_manager.remove(level=self._default_logger)