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();
}
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);
}
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);
}
}
Aggregations