def write(self, precommit_data: 'PrecommitData'): """ Write the human readable precommit data to the file for debugging :param precommit_data: :param path: path to record :return: """ filename: str = f"{precommit_data.block.height}" \ f"-{precommit_data.state_root_hash.hex()[:8]}" \ f"-{self._filename_suffix}" Logger.info( tag=_TAG, msg= f"PrecommitDataWriter.write() start (precommit: {precommit_data})") with open(os.path.join(self._dir_path, filename), 'w') as f: try: block = precommit_data.block json_dict = { "iconservice": __version__, "revision": precommit_data.revision, "block": block.to_dict(to_camel_case) if block is not None else None, "isStateRootHash": precommit_data.is_state_root_hash, "rcStateRootHash": precommit_data.rc_state_root_hash, "stateRootHash": precommit_data.state_root_hash, "prevBlockGenerator": precommit_data.prev_block_generator, "blockBatch": precommit_data.block_batch.to_list(), "rcBlockBatch": self._convert_rc_block_batch_to_list( precommit_data.rc_block_batch) } json.dump(json_dict, f, default=self._json_default) except Exception as e: Logger.exception( tag=_TAG, msg= f"Exception raised during writing the precommit-data: {e}") Logger.info(tag=_TAG, msg=f"PrecommitDataWriter.write() end")
def test_exception(self): try: raise Exception() except: Logger.exception(TAG, 'exception log')