use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.
the class FilterTest method testMinMaxFilterType.
/**
* Check if the filter works for MinMax value
*/
public void testMinMaxFilterType() throws Exception {
// Check the line
Integer maxLine = Integer.valueOf(120);
Integer minLine = Integer.valueOf(98);
Filter minMaxFilter = new MinMaxFilter(LogField.LINE, lethal, minLine, maxLine, false);
assertTrue("MinMax should have accepted this line value", minMaxFilter.applyTo(log1, lethal));
assertFalse("MinMax should have rejected this line value", minMaxFilter.applyTo(log2, lethal));
assertFalse("MinMax should have rejected this line value", minMaxFilter.applyTo(log3, lethal));
// Check the time
Date maxDate = df.parseIsoTimestamp("2013-08-07T15:10:10.512");
Date minDate = df.parseIsoTimestamp("2013-08-02T15:10:10.512");
Filter minMaxDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, minDate, maxDate, false);
assertTrue("MinMax should have accepted this timestamp", minMaxDateFilter.applyTo(log1, lethal));
assertFalse("MinMax should have rejected this timestamp", minMaxDateFilter.applyTo(log2, lethal));
assertFalse("MinMax should have rejected this timestamp", minMaxDateFilter.applyTo(log3, lethal));
// Log type
LogTypeHelper maxType = LogTypeHelper.NOTICE;
LogTypeHelper minType = LogTypeHelper.DEBUG;
Filter minMaxTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, minType, maxType, false);
assertTrue("MinMax should have accepted this log type", minMaxTypeFilter.applyTo(log1, lethal));
assertFalse("MinMax should have rejected this log type", minMaxTypeFilter.applyTo(log2, lethal));
assertFalse("MinMax should have rejected this log type", minMaxTypeFilter.applyTo(log3, lethal));
}
use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.
the class FilterTest method testMaxFilterType.
/**
* Check if the filter works for max value
*/
public void testMaxFilterType() throws Exception {
// Check the line
Integer maxLine = Integer.valueOf(120);
Filter maxFilter = new MinMaxFilter(LogField.LINE, lethal, null, maxLine, false);
assertTrue("Max should have accepted this line value", maxFilter.applyTo(log1, lethal));
Integer noMaxLine = Integer.valueOf(98);
Filter noMaxFilter = new MinMaxFilter(LogField.LINE, lethal, null, noMaxLine, false);
assertFalse("Min should have rejected this line value", noMaxFilter.applyTo(log1, lethal));
// Check the time
Date date = df.parseIsoTimestamp("2013-09-01T15:10:10.512");
Filter maxDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, null, date, false);
assertTrue("Max should have accepted this timestamp", maxDateFilter.applyTo(log1, lethal));
Date noDate = df.parseIsoTimestamp("2013-07-01T15:10:10.512");
Filter noMaxDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, null, noDate, false);
assertFalse("Max should have accepted this timestamp", noMaxDateFilter.applyTo(log1, lethal));
// Log type
LogTypeHelper maxType = LogTypeHelper.CRITICAL;
Filter maxTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, null, maxType, false);
assertTrue("Min should have accepted this log type", maxTypeFilter.applyTo(log1, lethal));
LogTypeHelper noMaxType = LogTypeHelper.TRACE;
Filter noMaxTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, null, noMaxType, false);
assertFalse("Min should have accepted this log type", noMaxTypeFilter.applyTo(log1, lethal));
}
use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.
the class FilterTest method testMinFilterType.
/**
* Check if the filter works for min value
*/
public void testMinFilterType() throws Exception {
// Check the line
Integer minLine = Integer.valueOf(99);
Filter minFilter = new MinMaxFilter(LogField.LINE, lethal, minLine, null, false);
assertTrue("Min should have accepted this line value", minFilter.applyTo(log1, lethal));
Integer noMinLine = Integer.valueOf(101);
Filter noMinFilter = new MinMaxFilter(LogField.LINE, lethal, noMinLine, null, false);
assertFalse("Min should have rejected this line value", noMinFilter.applyTo(log1, lethal));
// Check the time
Date date = df.parseIsoTimestamp("2013-08-01T15:10:10.512");
Filter minDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, date, null, false);
assertTrue("Min should have accepted this timestamp", minDateFilter.applyTo(log1, lethal));
Date noDate = df.parseIsoTimestamp("2013-08-15T15:10:10.512");
Filter noMinDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, noDate, null, false);
assertFalse("Min should have accepted this timestamp", noMinDateFilter.applyTo(log1, lethal));
// Log type
LogTypeHelper minType = LogTypeHelper.DEBUG;
Filter minTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, minType, null, false);
assertTrue("Min should have accepted this log type", minTypeFilter.applyTo(log1, lethal));
LogTypeHelper noMinType = LogTypeHelper.WARNING;
Filter noMinTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, noMinType, null, false);
assertFalse("Min should have accepted this log type", noMinTypeFilter.applyTo(log1, lethal));
}
use of com.cosylab.logging.engine.log.LogTypeHelper 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.LogTypeHelper 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;
}
Aggregations