Search in sources :

Example 11 with ACSLogParser

use of alma.acs.logging.engine.parser.ACSLogParser in project ACS by ACS-Community.

the class AntennaReductionTest method createLog.

private ILogEntry createLog(String logMsg) throws Exception {
    ACSLogParser parser = ACSLogParserFactory.getParser();
    long now = Calendar.getInstance().getTimeInMillis();
    SimpleDateFormat df = new IsoDateFormat();
    Date dt = new Date(now);
    StringBuffer dateSB = new StringBuffer();
    FieldPosition pos = new FieldPosition(0);
    df.format(dt, dateSB, pos);
    StringBuilder logStr = new StringBuilder("<Info TimeStamp=\"");
    logStr.append(dateSB.toString());
    logStr.append("\" Routine=\"CacheTest::testGet\" Host=\"this\" Process=\"test\" Thread=\"main\" Context=\"\"><![CDATA[");
    logStr.append(logMsg);
    logStr.append("]]></Info>");
    ILogEntry newLog = parser.parse(logStr.toString());
    return newLog;
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) ACSLogParser(alma.acs.logging.engine.parser.ACSLogParser) IsoDateFormat(alma.acs.util.IsoDateFormat) FieldPosition(java.text.FieldPosition) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 12 with ACSLogParser

use of alma.acs.logging.engine.parser.ACSLogParser in project ACS by ACS-Community.

the class LogProcessorTest method createLog.

private ILogEntry createLog(String logMsg) throws Exception {
    ACSLogParser parser = ACSLogParserFactory.getParser();
    long now = Calendar.getInstance().getTimeInMillis();
    SimpleDateFormat df = new IsoDateFormat();
    Date dt = new Date(now);
    StringBuffer dateSB = new StringBuffer();
    FieldPosition pos = new FieldPosition(0);
    df.format(dt, dateSB, pos);
    StringBuilder logStr = new StringBuilder("<Info TimeStamp=\"");
    logStr.append(dateSB.toString());
    logStr.append("\" Routine=\"CacheTest::testGet\" Host=\"this\" Process=\"test\" Thread=\"main\" Context=\"\"><![CDATA[");
    logStr.append(logMsg);
    logStr.append("]]></Info>");
    ILogEntry newLog = parser.parse(logStr.toString());
    return newLog;
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) ACSLogParser(alma.acs.logging.engine.parser.ACSLogParser) IsoDateFormat(alma.acs.util.IsoDateFormat) FieldPosition(java.text.FieldPosition) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 13 with ACSLogParser

use of alma.acs.logging.engine.parser.ACSLogParser 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

ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)13 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)11 IsoDateFormat (alma.acs.util.IsoDateFormat)5 FieldPosition (java.text.FieldPosition)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 ParserTypes (alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes)2 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)2 LogField (com.cosylab.logging.engine.log.LogField)2 Vector (java.util.Vector)2 IOHelper (alma.acs.logging.engine.io.IOHelper)1 XMLConverter (alma.acs.logging.tools.XMLConverter)1 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)1 Calendar (java.util.Calendar)1