docs: def Write(self, grr_message):
      """Write the message into the transaction log."""
      grr_message = grr_message.SerializeToString()
  
      try:
        with io.open(self.logfile, "wb") as fd:
          fd.write(grr_message)
      except (IOError, OSError):
        # Check if we're missing directories and try to create them.
        if not os.path.isdir(os.path.dirname(self.logfile)):
          try:
            os.makedirs(os.path.dirname(self.logfile))
            with io.open(self.logfile, "wb") as fd:
              fd.write(grr_message)
          except (IOError, OSError):
            logging.exception("Couldn't write nanny transaction log to %s",
                              self.logfile)