Search in sources :

Example 1 with ConnectedRecord

use of org.eclipse.titan.log.viewer.parsers.ConnectedRecord in project titan.EclipsePlug-ins by eclipse.

the class ValueReader method readLogRecordFromLogFile.

public LogRecord readLogRecordFromLogFile(final URI logFilePath, final EventObject event) throws IOException, ParseException {
    long offset = event.getRecordOffset();
    int length = event.getRecordLength();
    LogRecord logrecord = getLogRecord(logFilePath, offset, length);
    String message = logrecord.getMessage();
    EventType type = event.getType();
    switch(type) {
        case SEND:
            message = readSendEvent(message);
            break;
        case RECEIVE:
            message = readReceiveEvent(message);
            break;
        case SILENT_EVENT:
            message = getValue(logFilePath, offset, length);
            break;
        case ENQUEUED:
            message = readEnqueuedEvent(message);
            break;
        case SETVERDICT:
            ConnectedRecord[] connectedRecords = event.getConnectedRecords();
            if (connectedRecords != null) {
                StringBuilder messageBuilder = new StringBuilder("{ message := " + message.trim());
                if (connectedRecords.length > 0) {
                    messageBuilder.append(", causedBy := { ");
                }
                for (int i = 0; i < connectedRecords.length; i++) {
                    int eventNumber = i + 1;
                    ConnectedRecord connectedEvent = connectedRecords[i];
                    logrecord = getLogRecord(logFilePath, connectedEvent.getRecordOffset(), connectedEvent.getRecordLength());
                    messageBuilder.append("event" + eventNumber + " := { timestamp := " + logrecord.getTimestamp() + ", componentRef := " + logrecord.getComponentReference() + ", eventType := " + logrecord.getEventType() + ", sourceInfo := " + logrecord.getSourceInformation() + ", message := {" + logrecord.getMessage().trim() + "} }");
                }
                if (connectedRecords.length > 0) {
                    messageBuilder.append(" }");
                }
                message = messageBuilder.toString();
            }
            // $NON-NLS-1$
            message = message + "}\n";
            break;
        case PTC_CREATE:
        default:
            break;
    }
    logrecord.setMessage(message);
    return logrecord;
}
Also used : LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) EventType(org.eclipse.titan.log.viewer.views.msc.model.EventType) ConnectedRecord(org.eclipse.titan.log.viewer.parsers.ConnectedRecord)

Aggregations

ConnectedRecord (org.eclipse.titan.log.viewer.parsers.ConnectedRecord)1 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)1 EventType (org.eclipse.titan.log.viewer.views.msc.model.EventType)1