Beispiel #1
0
    def search(self, prnt=False, print_=False, **kwargs):
        """
            console.search(prnt, print_, **kwargs)
                Construct SearchCollectedLogs message with kwargs (see Logging.proto for
                documentation) and perform search query to a log collector.

                If prnt or print_ then the logs are pretty printed instead of returning.
        """
        q = make_message(SearchCollectedLogs, **kwargs)
        mxmsg = self.__connection.query(q,
                type=types.SEARCH_COLLECTED_LOGS_REQUEST, timeout=3,
                workflow='search-logs-%d' % random.randint(0, sys.maxint))
        if mxmsg.type != types.SEARCH_COLLECTED_LOGS_RESPONSE:
            # Beware: the following may or may not work; OperationFailed is a C-defined exception.
            raise OperationFailed, "invalid response of type %r received from backend" % mxmsg.type
        message = parse_message(LogEntriesMessage, mxmsg.message)
        del mxmsg
        les = list(message.log)
        del message

        if not print_ and not prnt:
            return l

        # let's print the results
        self.__print(les, q)
Beispiel #2
0
 def handle_message(self, mxmsg):
     if mxmsg.type == types.REPLAY_EVENTS_REQUEST:
         print "----------------------------------------------------------------------"
         query = mxclient.parse_message(
             ReplayCollectedEvents, mxmsg.message)
         print mxmsg
         print query
         count = self.__replay_events(mxmsg, query)
         print "Replied with %d events." % count
         self.no_response()
     else:
         self.__add_event(mxmsg)
         self.no_response()
         print ("Received an event type=%-4d id=%d;\t " +
                 "remembered entries: %d (max %d)") % \
                 (mxmsg.type, mxmsg.id, len(self.__events), self.__memory_size)
         print mxmsg
Beispiel #3
0
 def parse_message(self, type, mxmsg=None):
     """parse mxmsg.message with new Protobuf message of type `type'"""
     return parse_message(type,
             self.last_mxmsg.message if mxmsg is None else mxmsg.message)
Beispiel #4
0
 def parse_message(self, type, mxmsg=None):
     """parse mxmsg.message with new Protobuf message of type `type'"""
     return parse_message(type,
             self.last_mxmsg.message if mxmsg is None else mxmsg.message)