'Write the message into the transaction log.'

def WriteTransactionLog(self, grr_message):

    grr_message = grr_message.SerializeToString()
    logfile = self._GetLogFilename()
    try:
        with open(logfile, 'wb') as fd:
            fd.write(grr_message)
    except (IOError, OSError):
        if (not os.path.isdir(os.path.dirname(logfile))):
            try:
                os.makedirs(os.path.dirname(logfile))
                with open(logfile, 'wb') as fd:
                    fd.write(grr_message)
            except (IOError, OSError):
                logging.exception("Couldn't    write    nanny    transaction    log    to    %s", logfile)
