Search in sources :

Example 6 with LogEntry

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

the class CacheUtils method fromCacheString.

/**
	 * Build a log out of its string representation
	 * 
	 * @param str The string representing a log
	 * @return The log
	 */
public static synchronized ILogEntry fromCacheString(String str) throws LogEngineException {
    String[] strs = str.split(SEPARATOR);
    long millis = 0;
    try {
        synchronized (dateFormat) {
            millis = dateFormat.parse(strs[0]).getTime();
        }
    } catch (ParseException e) {
        System.err.println("Error parsing the date: " + strs[0]);
        throw new LogEngineException(e);
    }
    Integer entrytype = new Integer(strs[1]);
    String srcObject = null;
    if (strs.length > 2) {
        srcObject = strs[2];
    }
    String fileNM = null;
    if (strs.length > 3) {
        fileNM = strs[3];
    }
    Integer line = null;
    if (strs.length > 4 && strs[4].length() != 0) {
        line = new Integer(strs[4]);
    }
    String routine = null;
    if (strs.length > 5) {
        routine = strs[5];
    }
    String host = null;
    if (strs.length > 6) {
        host = strs[6];
    }
    String process = null;
    if (strs.length > 7) {
        process = strs[7];
    }
    String context = null;
    if (strs.length > 8) {
        context = strs[8];
    }
    String thread = null;
    if (strs.length > 9) {
        thread = strs[9];
    }
    String logid = null;
    if (strs.length > 10) {
        logid = strs[10];
    }
    Integer priority = null;
    if (strs.length > 11 && strs[11].length() > 0) {
        priority = new Integer(strs[11]);
    }
    String uri = null;
    if (strs.length > 12) {
        uri = strs[12];
    }
    String stackid = null;
    if (strs.length > 13) {
        stackid = strs[13];
    }
    Integer stacklevel = null;
    if (strs.length > 14 && strs[14].length() > 0) {
        Integer.parseInt(strs[14]);
    }
    String logmessage = null;
    if (strs.length > 15) {
        logmessage = strs[15];
    }
    String audience = null;
    if (strs.length > 16) {
        audience = strs[16];
    }
    String array = null;
    if (strs.length > 17) {
        array = strs[17];
    }
    String antenna = null;
    if (strs.length > 18) {
        antenna = strs[18];
    }
    Vector<ILogEntry.AdditionalData> addDatas = null;
    if (strs.length > LogField.values().length) {
        addDatas = new Vector<ILogEntry.AdditionalData>();
        for (int t = LogField.values().length; t < strs.length; t += 2) {
            addDatas.add(new AdditionalData(strs[t], strs[t + 1]));
        }
    }
    return new LogEntry(millis, entrytype, fileNM, line, routine, host, process, context, thread, logid, priority, uri, stackid, stacklevel, logmessage, srcObject, audience, array, antenna, addDatas);
}
Also used : AdditionalData(com.cosylab.logging.engine.log.ILogEntry.AdditionalData) LogEngineException(com.cosylab.logging.engine.LogEngineException) ParseException(java.text.ParseException) ILogEntry(com.cosylab.logging.engine.log.ILogEntry) LogEntry(com.cosylab.logging.engine.log.LogEntry)

Example 7 with LogEntry

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

the class FiltersVectorTest method setUp.

@Override
protected void setUp() throws Exception {
    filters = new FiltersVector();
    assertNotNull(filters);
    log1 = new LogEntry(df.parseIsoTimestamp("2013-08-04T15:10:10.512").getTime(), LogTypeHelper.fromAcsCoreLevel(AcsLogLevelDefinition.INFO).ordinal(), "File.java", 100, "File#routine()", "alma.hq.eso.org", "javaProcess", "context", "java thread", "log id", 5, "URI", "stack id", 12, "A message for a log", "source object", "Audience", "array name", "antenna name", null);
    log2 = new LogEntry(df.parseIsoTimestamp("2013-08-01T15:10:10.512").getTime(), LogTypeHelper.fromAcsCoreLevel(AcsLogLevelDefinition.TRACE).ordinal(), "File.java", 95, "File#routine()", "alma.hq.eso.org", "javaProcess", "context", "java thread", "log id", 5, "URI", "stack id", 12, "A message for log2", "source object", "Audience", "array name", "antenna name", null);
    log3 = new LogEntry(df.parseIsoTimestamp("2013-08-10T15:10:10.512").getTime(), LogTypeHelper.fromAcsCoreLevel(AcsLogLevelDefinition.WARNING).ordinal(), "File.java", 130, "File#routine()", "alma.hq.eso.org", "javaProcess", "context", "java thread", "log id", 5, "URI", "stack id", 15, "A message for log2", "source object", "Audience", "array name", "antenna name", null);
    super.setUp();
}
Also used : FiltersVector(com.cosylab.logging.engine.FiltersVector) LogEntry(com.cosylab.logging.engine.log.LogEntry)

Example 8 with LogEntry

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

the class FilterTest method setUp.

@Override
protected void setUp() throws Exception {
    log1 = new LogEntry(df.parseIsoTimestamp("2013-08-04T15:10:10.512").getTime(), LogTypeHelper.fromAcsCoreLevel(AcsLogLevelDefinition.INFO).ordinal(), "File.java", 100, "File#routine()", "alma.hq.eso.org", "javaProcess", "context", "java thread", "log id", 5, "URI", "stack id", 12, "A message for a log", "source object", "Audience", "array name", "antenna name", null);
    log2 = new LogEntry(df.parseIsoTimestamp("2013-08-01T15:10:10.512").getTime(), LogTypeHelper.fromAcsCoreLevel(AcsLogLevelDefinition.TRACE).ordinal(), "File.java", 95, "File#routine()", "alma.hq.eso.org", "javaProcess", "context", "java thread", "log id", 5, "URI", "stack id", 12, "A message for a log", "source object", "Audience", "array name", "antenna name", null);
    log3 = new LogEntry(df.parseIsoTimestamp("2013-08-10T15:10:10.512").getTime(), LogTypeHelper.fromAcsCoreLevel(AcsLogLevelDefinition.WARNING).ordinal(), "File.java", 130, "File#routine()", "alma.hq.eso.org", "javaProcess", "context", "java thread", "log id", 5, "URI", "stack id", 12, "A message for a log", "source object", "Audience", "array name", "antenna name", null);
    super.setUp();
}
Also used : LogEntry(com.cosylab.logging.engine.log.LogEntry)

Example 9 with LogEntry

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

the class LogFileCache method fromCacheString.

private ILogEntry fromCacheString(String str) {
    String[] strs = str.split(SEPARATOR);
    Long millis = new Long(strs[0]);
    Integer entrytype = new Integer(strs[1]);
    String srcObject = null;
    if (strs.length > 2) {
        srcObject = strs[2];
    }
    String fileNM = null;
    if (strs.length > 3) {
        fileNM = strs[3];
    }
    Integer line = null;
    if (strs.length > 4 && strs[4].length() != 0) {
        line = new Integer(strs[4]);
    }
    String routine = null;
    if (strs.length > 5) {
        routine = strs[5];
    }
    String host = null;
    if (strs.length > 6) {
        host = strs[6];
    }
    String process = null;
    if (strs.length > 7) {
        process = strs[7];
    }
    String context = null;
    if (strs.length > 8) {
        context = strs[8];
    }
    String thread = null;
    if (strs.length > 9) {
        thread = strs[9];
    }
    String logid = null;
    if (strs.length > 10) {
        logid = strs[10];
    }
    Integer priority = null;
    if (strs.length > 11 && strs[11].length() > 0) {
        priority = new Integer(strs[11]);
    }
    String uri = null;
    if (strs.length > 12) {
        uri = strs[12];
    }
    String stackid = null;
    if (strs.length > 13) {
        stackid = strs[13];
    }
    Integer stacklevel = null;
    if (strs.length > 14 && strs[14].length() > 0) {
        stacklevel = Integer.parseInt(strs[14]);
    }
    String logmessage = null;
    if (strs.length > 15) {
        logmessage = strs[15];
    }
    String audience = null;
    if (strs.length > 16) {
        audience = strs[16];
    }
    String array = null;
    if (strs.length > 17) {
        array = strs[17];
    }
    String antenna = null;
    if (strs.length > 18) {
        antenna = strs[18];
    }
    Vector<ILogEntry.AdditionalData> addDatas = null;
    if (strs.length > LogField.values().length) {
        addDatas = new Vector<ILogEntry.AdditionalData>();
        for (int t = LogField.values().length; t < strs.length; t += 2) {
            addDatas.add(new AdditionalData(strs[t], strs[t + 1]));
        }
    }
    return new LogEntry(millis, entrytype, fileNM, line, routine, host, process, context, thread, logid, priority, uri, stackid, stacklevel, logmessage, srcObject, audience, array, antenna, addDatas);
}
Also used : AdditionalData(com.cosylab.logging.engine.log.ILogEntry.AdditionalData) ILogEntry(com.cosylab.logging.engine.log.ILogEntry) LogEntry(com.cosylab.logging.engine.log.LogEntry)

Aggregations

LogEntry (com.cosylab.logging.engine.log.LogEntry)9 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)7 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)5 LogParseException (com.cosylab.logging.engine.ACS.LogParseException)3 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)3 FiltersVector (com.cosylab.logging.engine.FiltersVector)1 LogEngineException (com.cosylab.logging.engine.LogEngineException)1 LogEntryXML (com.cosylab.logging.engine.log.LogEntryXML)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ParseException (java.text.ParseException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Document (org.w3c.dom.Document)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1