code: def format(self, record: logging.LogRecord) -> str:
          
          msg: Union[str, dict] = record.msg
          if not isinstance(record.msg, dict):
              msg = {self.default_msg_fieldname: msg}
  
          if record.exc_info:  # type: ignore
              msg["exc_info"] = record.exc_info
          if record.exc_text:  # type: ignore
              msg["exc_text"] = record.exc_text  # type: ignore
  
          return self.serializer(msg, default=self._default_handler)
docs: Formats a record and serializes it as a JSON str. If record message isnt
          already a dict, initializes a new dict and uses `default_msg_fieldname`
          as a key as the record msg as the value.