def parse_log(expressions, state): """Parse a log.""" device = state['input_device'] if state['write_original']: originalOutput = OutputFileDevice(state, state['write_original'], True) # While there is a new line, parse it. line = True # For the first condition. while line: # If the line contains non-UTF8 chars it could raise an exception. state['input_line'] += 1 line = device.read_line().rstrip("\r\n") # If EOF or the line is empty, continue. if not line or line == "": continue # Write original log if needed if state['write_original']: originalOutput.write(line) # We can get exceptions if the file contains output from two # different applications since the logs are messed up. try: match_line(line, expressions, state) except Exception as ex: # pylint: disable=W0703 exc_traceback = exc_info()[2] stacktraces = extract_tb(exc_traceback) log_error("[ScriptError] %s %s" % (str(stacktraces[-1]), ex), state)
def on_different_type_names(match, state): """It happens when there isn't TypeObject and type names are different.""" topic = get_topic_name(match[0], state) type1 = get_type_name(match[1], state) type2 = get_type_name(match[2], state) log_error( "[LP-18] Cannot match remote entity in topic '%s': " % (topic) + "Different type names found ('%s', '%s')" % (type1, type2), state)
def on_shmem_queue_full(match, state): """It happens when the ShareMemory queue is full and data is dropped.""" port = get_port_number(match[0], state) port_name = get_port_name(int(match[0], 16)) count_max = match[1] max_size = match[2] log_cfg( "ShareMemory limits for queue %s (%s) are: max_num=%s, max_size=%s" % (port, port_name, count_max, max_size), state) log_error( "[LP-19] Sample dropped because ShareMemory queue %s is full." % port, state)
def on_deserialize_failure(match, state): """It happens when the reader is not able to deserialize a sample.""" kind = "keyed" if match[0] == "CstReaderCollator" else "unkeyed" log_error("[LP-17] Cannot deserialize %s sample" % kind, state)
def on_typecode_inconsistency(match, state): """It happens when RS detects two different types with same name.""" log_error("RS found two different types with the same name: %s" % match[0], state)
def on_write_max_blocking_time_expired(match, state): """It happens when the blocking time expired.""" log_error("[LP-13] Write maximum blocking time expired", state)
def on_batch_serialize_failure(match, state): """It happens when the batch serialization fails.""" log_error("Cannot serialize batch sample", state)
def on_send_from_deleted_writer(match, state): """It happens when the writer is deleted.""" log_error("[LP-14] Cannot write because DataWriter has been deleted", state)
def on_fail_serialize(match, state): """It happens when the serialization fails.""" log_error("[LP-8] Cannot serialize sample", state)
def on_typecode_not_found(match, state): """It happens when RS doesn't have the type code for a topic.""" log_error("Typecode for %s is unavailable. Route will not work" % match[0], state)
def on_instance_not_found(match, state): """It happens when the instance is not found.""" log_error("[LP-3] Cannot write unregistered instance.", state)
def on_route_creation_failure(match, state): """It happens when the route cannot be created.""" log_error("Cannot create RS route.", state)
def on_duplicate_topic_name_error(match, state): """It happens when there is a topic name duplication.""" topic = get_topic_name(match[0], state) log_error("[LP-2] Topic name already in use by another topic: %s" % topic, state)
def on_large_configuration_value(match, state): """It happens when the configuration value is too long, can't be parsed.""" log_error( "[LP-16] Cannot initialize Monitoring: " + "string too long in RS configuration", state)
def on_get_unkeyed_key(match, state): """It happens when getting key from unkeyed sample.""" log_error("[LP-5] Try to get key from unkeyed type.", state)
def on_delete_topic_before_cft(match, state): """It happens when deleting a topic before its CFT.""" num_cft = match[0] log_error( "[LP-7] Cannot delete topic before its %s ContentFilteredTopics" % num_cft, state)
def on_inconsistent_transport_discovery_configuration(match, state): """It happens for inconsistencies in the discovery configuration.""" log_error("Inconsistent transport/discovery configuration", state)
def on_fail_delete_flowcontrollers(match, state): """It happens when delete FC fails.""" num_flowcontrol = match[0] log_error( "[LP-15] Cannot delete %s FlowControllers" % (num_flowcontrol) + " from delete_contained_entities", state)