use of com.cosylab.logging.engine.log.LogEntry in project ACS by ACS-Community.
the class ACSLogParserDOM method parse.
/* (non-Javadoc)
* @see com.cosylab.logging.engine.ACS.ACSLogParser#parse(java.lang.String)
*/
public synchronized ILogEntry parse(String string) throws LogParseException {
Document document = null;
try {
document = builder.parse(new InputSource(new StringReader(string)));
} catch (IOException ioe) {
// cannot get here
System.err.println("Exception parsing " + ioe.getMessage());
throw new LogParseException(ioe);
} catch (Exception e) {
/* There was an exception parsing the log, but before giving up
* we try to fix markup issues inside the text that is contained in the XML */
document = null;
String newLogString = XmlNormalizer.normalizeXMLEmbeddedTextOnly(string);
try {
document = builder.parse(new InputSource(new StringReader(newLogString)));
System.out.println("Fatal error recovered:");
System.out.println("\tOriginal log entry: " + string);
System.out.println("\tCleaned log entry: " + newLogString + "\n");
} catch (IOException ex1) {
System.err.println("Failed to parse the following log entry:");
System.err.println(string);
System.err.println("with IO exception ");
throw new LogParseException(ex1);
} catch (SAXException ex2) {
System.err.println("Failed to parse the following log entry:");
System.err.println(string);
System.err.println("with parser exception ");
throw new LogParseException(ex2);
}
}
return new LogEntry(new LogEntryXML(document.getFirstChild()));
}
use of com.cosylab.logging.engine.log.LogEntry in project ACS by ACS-Community.
the class ACSLogParserVTD method parse.
/**
* Implements required method of ACSLogParser interface.
*
* @param xmlString the XML string to parse
* @throws LogParseException when problems are encountered parsing an XML message.
* @see ACSLogParser
*/
public synchronized ILogEntry parse(String xmlString) throws LogParseException {
if (xmlString == null || xmlString.length() == 0) {
throw new IllegalArgumentException("Invalid string to parse");
}
LogEntry retVal = null;
byte[] bytesArray = xmlString.getBytes();
try {
try {
VTDGen_clear.invoke(vtdGen, nullObj);
VTDGen_setDoc.invoke(vtdGen, bytesArray);
// set namespace awareness to false for now
VTDGen_parse.invoke(vtdGen, false);
} catch (Exception e) {
/* There was an exception parsing the log, but before giving up
* we try to fix markup issues inside the text that is contained in the XML */
VTDGen_clear.invoke(vtdGen, nullObj);
xmlString = XmlNormalizer.normalizeXMLEmbeddedTextOnly(xmlString);
bytesArray = xmlString.getBytes();
VTDGen_setDoc.invoke(vtdGen, xmlString.getBytes());
VTDGen_parse.invoke(vtdGen, false);
}
retVal = makeLogEntryFromParsedXML(bytesArray, xmlString);
} catch (Exception ex) {
throw new LogParseException("Error parsing with VTD!", ex);
}
return retVal;
}
use of com.cosylab.logging.engine.log.LogEntry in project ACS by ACS-Community.
the class AntennaRule method getReducedLog.
@Override
public ILogEntry getReducedLog() {
String reducedItems = getReducedItems();
if (reducedItems == null || reducedItems.isEmpty()) {
return initialLog;
}
Long milliseconds = (Long) initialLog.getField(LogField.TIMESTAMP);
Integer entrytype = ((LogTypeHelper) initialLog.getField(LogField.ENTRYTYPE)).ordinal();
String file = (String) initialLog.getField(LogField.FILE);
Integer line = (Integer) initialLog.getField(LogField.LINE);
String routine = (String) initialLog.getField(LogField.ROUTINE);
String host = (String) initialLog.getField(LogField.HOST);
String process = (String) initialLog.getField(LogField.PROCESS);
String context = (String) initialLog.getField(LogField.CONTEXT);
String thread = (String) initialLog.getField(LogField.THREAD);
String logid = (String) initialLog.getField(LogField.LOGID);
Integer priority = (Integer) initialLog.getField(LogField.PRIORITY);
String uri = (String) initialLog.getField(LogField.URI);
String stackid = (String) initialLog.getField(LogField.STACKID);
Integer stacklevel = (Integer) initialLog.getField(LogField.STACKLEVEL);
String logmessage = (String) initialLog.getField(LogField.LOGMESSAGE) + " and also " + reducedItems;
String srcObject = (String) initialLog.getField(LogField.SOURCEOBJECT);
String audience = (String) initialLog.getField(LogField.AUDIENCE);
String array = (String) initialLog.getField(LogField.ARRAY);
String antenna = (String) initialLog.getField(LogField.ANTENNA);
Vector<AdditionalData> addDatas = initialLog.getAdditionalData();
LogEntry ret = new LogEntry(milliseconds, entrytype, file, line, routine, host, process, context, thread, logid, priority, uri, stackid, stacklevel, logmessage, srcObject, audience, array, antenna, addDatas);
return ret;
}
use of com.cosylab.logging.engine.log.LogEntry in project ACS by ACS-Community.
the class SourceAntennaRule method getReducedLog.
@Override
public ILogEntry getReducedLog() {
if (sourceObjects == null || sourceObjects.size() <= 1) {
return initialLog;
}
Long milliseconds = (Long) initialLog.getField(LogField.TIMESTAMP);
Integer entrytype = ((LogTypeHelper) initialLog.getField(LogField.ENTRYTYPE)).ordinal();
String file = (String) initialLog.getField(LogField.FILE);
Integer line = (Integer) initialLog.getField(LogField.LINE);
String routine = (String) initialLog.getField(LogField.ROUTINE);
String host = (String) initialLog.getField(LogField.HOST);
String process = (String) initialLog.getField(LogField.PROCESS);
String context = (String) initialLog.getField(LogField.CONTEXT);
String thread = (String) initialLog.getField(LogField.THREAD);
String logid = (String) initialLog.getField(LogField.LOGID);
Integer priority = (Integer) initialLog.getField(LogField.PRIORITY);
String uri = (String) initialLog.getField(LogField.URI);
String stackid = (String) initialLog.getField(LogField.STACKID);
Integer stacklevel = (Integer) initialLog.getField(LogField.STACKLEVEL);
String logmessage = initialLogMessage;
String srcObject = reducedSource;
String audience = (String) initialLog.getField(LogField.AUDIENCE);
String array = (String) initialLog.getField(LogField.ARRAY);
String antenna = (String) initialLog.getField(LogField.ANTENNA);
Vector<AdditionalData> addDatas = initialLog.getAdditionalData();
if (addDatas == null) {
addDatas = new Vector<ILogEntry.AdditionalData>();
}
for (String ant : sourceObjects) {
AdditionalData ad = new AdditionalData(additionalDataName, ant);
addDatas.add(ad);
}
LogEntry ret = new LogEntry(milliseconds, entrytype, file, line, routine, host, process, context, thread, logid, priority, uri, stackid, stacklevel, logmessage, srcObject, audience, array, antenna, addDatas);
return ret;
}
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);
}
Aggregations