class_docstr: Wraps a Transport implementation and logs traffic to the Python logging infrastructure.
class_docstr_tok: ["Wraps","a","Transport","implementation","and","logs","traffic","to","the","Python","logging","infrastructure","."]
code: def write(self, data, timeout_sec):
      timeout_str = (
          f"{timeout_sec:5.2f}s"
          if timeout_sec is not None
          else " None "
      )
      try:
          self.child.write(data, timeout_sec)
      except IoTimeoutError:
          self.logger.log(
              self.level,
              "%s: write {%s}       <- [%3d B]: [IoTimeoutError %s]",
              self.name,
              timeout_str,
              len(data),
              timeout_str,
          )
          raise
      except Exception as err:
          self.logger.log(
              self.level,
              "%s: write {%s}       <- [%3d B]: [err: %s]",
              self.name,
              timeout_str,
              len(data),
              err.__class__.__name__,
              exc_info=1,
          )
          raise err
  
      hex_lines = self._to_hex(data)
      if len(hex_lines) > 1:
          self.logger.log(
              self.level,
              "%s: write {%s}        <- [%3d B]:\n%s",
              self.name,
              timeout_str,
              len(data),
              "\n".join(hex_lines),
          )
      else:
          self.logger.log(
              self.level,
              "%s: write {%s}        <- [%3d B]: %s",
              self.name,
              timeout_str,
              len(data),
              hex_lines[0],
          )
  
imports: import abc
  import logging
  import string
  import typing
  from .project_api.server import IoTimeoutError, TransportTimeouts
  from .project_api.server import TransportClosedError
label_desc: Use image node_id 7 for calling the TransportLogger obj's underlying member method code with example usage: obj.write(data, timeout_sec) without return types