Exemplo n.º 1
0
    def __sendLogToServer(self, logBundle=None):
        """
    Send log to the SystemLogging service.

    :params logBundle: list of logs ready to be send to the service
    """
        from DIRAC.Core.DISET.RPCClient import RPCClient
        if logBundle:
            self.__transactions.append(logBundle)
        transactionsLength = len(self.__transactions)
        if transactionsLength > 100:
            del self.__transactions[:transactionsLength - 100]
            transactionsLength = 100

        try:
            oSock = RPCClient("Framework/SystemLogging")
        except Exception:
            return False

        while transactionsLength:
            result = oSock.addMessages(self.__transactions[0], self.__site,
                                       self.__hostname)
            if result['OK']:
                transactionsLength = transactionsLength - 1
                self.__transactions.pop(0)
            else:
                return False
        return True