def _log_test_output(dbg_info: DebugInfo) -> None: """Uses all methods of DebugInfo class to append data in different format :param dbg_info: instance used for logging """ dbg_info.append_section("SECTION") dbg_info.append("-test-line-") dbg_info.append_binary_section("bin", b"\x00\x11\x22\xFF") dbg_info.append_binary_data("data", b"\x00\x11\x22") dbg_info.append_hex_data(b"\x00\x11\x22\x00\x11\x22\x00\x11\x22\x00\x11\x22")
def _log_test_output(dbg_info: DebugInfo) -> None: """Uses all methods of DebugInfo class to append data in different format :param dbg_info: instance used for logging """ dbg_info.append_section('SECTION') dbg_info.append('-test-line-') dbg_info.append_binary_section('bin', b'\x00\x11\x22\xFF') dbg_info.append_binary_data('data', b'\x00\x11\x22') dbg_info.append_hex_data( b'\x00\x11\x22\x00\x11\x22\x00\x11\x22\x00\x11\x22')
def export(self, dbg_info: DebugInfo = DebugInfo.disabled()) -> bytes: """Export instance into binary form (serialization). :param dbg_info: optional instance providing debug info about exported content :return: binary form """ self._validate_data() self._header.length = self.size raw_data = self._header.export() dbg_info.append_binary_data("header", raw_data) raw_data += pack(">4B", 0, self.nonce_len, 0, self.mac_len) dbg_info.append("nonce=" + self.nonce.hex()) dbg_info.append("mac=" + self.mac.hex()) raw_data += self.data return raw_data