Search in sources :

Example 11 with LogField

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

the class LogFileCache method toCacheString.

protected String toCacheString(ILogEntry log) {
    sb.delete(0, sb.length());
    for (LogField field : LogField.values()) {
        Object obj = log.getField(field);
        if (obj != null) {
            if (obj instanceof Date) {
                sb.append(((Date) obj).getTime());
            } else if (obj instanceof LogTypeHelper) {
                sb.append(((LogTypeHelper) obj).ordinal());
            } else {
                sb.append(obj.toString());
            }
        }
        sb.append((char) 0);
    }
    if (log.hasDatas()) {
        Vector<ILogEntry.AdditionalData> datas = log.getAdditionalData();
        for (int t = 0; t < datas.size(); t++) {
            ILogEntry.AdditionalData data = datas.get(t);
            sb.append(data.name);
            sb.append(SEPARATOR);
            sb.append(data.value);
            sb.append(SEPARATOR);
        }
    }
    return sb.toString();
}
Also used : AdditionalData(com.cosylab.logging.engine.log.ILogEntry.AdditionalData) ILogEntry(com.cosylab.logging.engine.log.ILogEntry) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) LogField(com.cosylab.logging.engine.log.LogField) Date(java.util.Date) AdditionalData(com.cosylab.logging.engine.log.ILogEntry.AdditionalData)

Example 12 with LogField

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

the class ConvertersTest method testColumnsVector.

/**
	 * Test the setting of the columns with a collection of {@link LogField}
	 * 
	 * @throws Exception
	 */
public void testColumnsVector() throws Exception {
    Vector<LogField> cols = new Vector<LogField>();
    assertNotNull(cols);
    cols.add(LogField.URI);
    cols.add(LogField.CONTEXT);
    TextConverter converter = new TextConverter(null);
    assertNotNull(converter);
    converter.setCols(cols, false);
    String ret = converter.convert(logToConvert);
    assertNotNull(ret);
    String expected = uri.replaceAll("\"", "") + " " + context.replaceAll("\"", "") + "\n";
    assertEquals(expected, ret);
}
Also used : TextConverter(alma.acs.logging.tools.TextConverter) Vector(java.util.Vector) LogField(com.cosylab.logging.engine.log.LogField)

Example 13 with LogField

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

the class ConvertersTest method testXML.

/**
	 * Test the XML conversion
	 * 
	 * @throws Exception
	 */
public void testXML() throws Exception {
    XMLConverter converter = new XMLConverter();
    assertNotNull(converter);
    String ret = converter.convert(logToConvert);
    assertNotNull(ret);
    ParserTypes type = ParserTypes.VTD;
    ACSLogParser parser = ACSLogParserFactory.getParser(type);
    ILogEntry log = parser.parse(ret);
    assertNotNull(log);
    for (LogField f : LogField.values()) {
        Object original = logToConvert.getField(f);
        Object converted = log.getField(f);
        assertEquals(original, converted);
    }
    Vector<AdditionalData> originalData = logToConvert.getAdditionalData();
    assertNotNull(originalData);
    Vector<AdditionalData> convertedData = log.getAdditionalData();
    assertNotNull(convertedData);
    assertEquals(originalData.size(), convertedData.size());
    for (AdditionalData ad : originalData) {
        boolean found = false;
        String name = ad.name;
        String val = ad.value;
        for (AdditionalData adConverted : convertedData) {
            if (name.equals(adConverted.name)) {
                found = true;
                assertEquals(val, adConverted.value);
                break;
            }
        }
        assertTrue("Additional data not found", found);
    }
}
Also used : AdditionalData(com.cosylab.logging.engine.log.ILogEntry.AdditionalData) ILogEntry(com.cosylab.logging.engine.log.ILogEntry) XMLConverter(alma.acs.logging.tools.XMLConverter) ParserTypes(alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes) ACSLogParser(alma.acs.logging.engine.parser.ACSLogParser) 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