Search in sources :

Example 6 with LogField

use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.

the class LogConverter method setCols.

/**
	 * Set the columns to write in the converted string
	 * 
	 * @param columns A vector of LogField representing the field to
	 * 					write in the converted string
	 * @param additionlData <code>true</code> if the additional data must be
	 * 			appended in the last position of the converted string
	 * 
	 * @see colIndexVector
	 */
public void setCols(Collection<LogField> columns, boolean additionlData) {
    if ((columns == null || columns.isEmpty()) && !additionlData) {
        throw new IllegalArgumentException("The columns can't be null nor empty");
    }
    StringBuilder cols = new StringBuilder();
    for (LogField f : columns) {
        cols.append(f.id);
    }
    if (additionlData) {
        cols.append(ADDITIONAL_DATA_ID);
    }
    setCols(cols.toString());
}
Also used : LogField(com.cosylab.logging.engine.log.LogField)

Example 7 with LogField

use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.

the class DetailedLogTable method setupContent.

/**
	 * Fill the table with the fields of the given log.
	 * 
	 * @param log The log whose content is shown in the table
	 */
public void setupContent(ILogEntry log) {
    if (log == null) {
        setEmptyContent();
        return;
    }
    // The number of rows in the table is given by the number of fields
    // of each LogEntry plus the number of the "data" elements for the selected log
    Vector<ILogEntry.AdditionalData> additionalData = log.getAdditionalData();
    rowsNum = LogField.values().length;
    if (additionalData != null) {
        rowsNum += additionalData.size();
    }
    if (rowsNum > 0) {
        nameValue = new String[rowsNum][2];
        for (int i = 0; i < LogField.values().length; i++) {
            LogField field = LogField.values()[i];
            nameValue[i][0] = "<HTML><B>" + field.getName() + "</B>";
            Object obj = log.getField(field);
            if (obj != null) {
                if (field == LogField.ENTRYTYPE) {
                    nameValue[i][1] = obj.toString();
                    dataModel.logType = (LogTypeHelper) obj;
                } else if (field == LogField.TIMESTAMP) {
                    SimpleDateFormat df = new IsoDateFormat();
                    Date dt = new Date((Long) obj);
                    StringBuffer dateSB = new StringBuffer();
                    java.text.FieldPosition pos = new java.text.FieldPosition(0);
                    df.format(dt, dateSB, pos);
                    nameValue[i][1] = dateSB.toString();
                } else {
                    nameValue[i][1] = obj.toString();
                }
            } else {
                nameValue[i][1] = "";
            }
        }
        for (int i = LogField.values().length; i < rowsNum; i++) {
            nameValue[i][0] = "<HTML><B>Additional</B> <I>" + additionalData.get(i - LogField.values().length).name + "</I>";
            String temp = (String) additionalData.get(i - LogField.values().length).value;
            nameValue[i][1] = temp;
        }
        dataModel.fireTableDataChanged();
    }
}
Also used : IsoDateFormat(alma.acs.util.IsoDateFormat) LogField(com.cosylab.logging.engine.log.LogField) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat)

Example 8 with LogField

use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.

the class LogEntryTest method testGetField.

public void testGetField() {
    //Object getField(int fieldIndex)
    Object actualField = null;
    String curFieldDesc = null;
    Object expectedField = "maciHeartbeatController.cpp";
    LogField fileField = LogField.FILE;
    actualField = log.getField(LogField.FILE);
    assertEquals("The two logs are not equal.", expectedField, actualField);
}
Also used : LogField(com.cosylab.logging.engine.log.LogField)

Example 9 with LogField

use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.

the class LogEntryTest method testGetFieldClass.

public void testGetFieldClass(String currentFieldDesc) {
    //Class getFieldClass(int fieldIndex)
    Class actualFieldClass = null;
    Class curFieldClass = null;
    String curFieldDesc = null;
    currentFieldDesc = "File";
    Class expectedFieldClass = String.class;
    for (LogField f : LogField.values()) {
        curFieldDesc = f.getName();
        // can be anything: timstamp, entrytype, field
        if (curFieldDesc.equals(currentFieldDesc))
            curFieldClass = f.getClass();
    // gets the class of the "File" which is String
    }
    assertEquals("The two logs are not equal.", expectedFieldClass, actualFieldClass);
}
Also used : LogField(com.cosylab.logging.engine.log.LogField)

Example 10 with LogField

use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.

the class LogEntryTable method showFieldChooser.

/**
	 * Displays the field chooser dialog.
	 * <p>
	 * Creation date: (1/2/2002 23:20:27)
	 */
public void showFieldChooser() {
    String[] fieldNames = new String[LogField.values().length];
    int t = 0;
    for (LogField f : LogField.values()) {
        fieldNames[t++] = f.getName();
    }
    boolean[] fieldVisible = getVisibleColumns(true);
    if (fieldChooser == null) {
        fieldChooser = new FieldChooserDialog(loggingClient);
    }
    fieldChooser.setupFields(fieldNames, fieldVisible);
    fieldChooser.setVisible(true);
    if (fieldChooser.getModalResult() == DialogExitAction.CANCEL) {
        return;
    }
    boolean[] newFields = fieldChooser.getFields();
    for (int i = 0; i < LogField.values().length; i++) {
        if (newFields[i] != fieldVisible[i]) {
            if (newFields[i])
                showColumn(i + 1);
            else
                hideColumn(i + 1);
        }
    }
}
Also used : FieldChooserDialog(com.cosylab.logging.settings.FieldChooserDialog) LogField(com.cosylab.logging.engine.log.LogField)

Aggregations

LogField (com.cosylab.logging.engine.log.LogField)13 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)3 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)3 Date (java.util.Date)3 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)2 IsoDateFormat (alma.acs.util.IsoDateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Vector (java.util.Vector)2 IOHelper (alma.acs.logging.engine.io.IOHelper)1 ParserTypes (alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes)1 TextConverter (alma.acs.logging.tools.TextConverter)1 XMLConverter (alma.acs.logging.tools.XMLConverter)1 Constraint (com.cosylab.logging.engine.Filter.Constraint)1 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)1 FieldChooserDialog (com.cosylab.logging.settings.FieldChooserDialog)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1