use of com.cosylab.logging.engine.FiltersVector in project ACS by ACS-Community.
the class FilterChooserDialog method applyFilters.
/**
* Apply the filters in the table of logs
*
*/
private void applyFilters() {
FiltersVector newFilters = new FiltersVector();
for (CheckListTableEntry entry : filterList.getEntries()) {
newFilters.addFilter((Filter) entry.getItem(), entry.isActive());
}
filterable.setFilters(newFilters, false);
}
use of com.cosylab.logging.engine.FiltersVector in project ACS by ACS-Community.
the class LCEngine method addFilter.
/**
* Add a new filters to the vector of filters to apply to the incoming logs
* before sending to the listeners.
* <P>
* The filter is applied as active.
*
* @param filter
* The not null filter to add
*/
public void addFilter(Filter filter) {
if (filter == null) {
throw new IllegalArgumentException("The filter can't be null");
}
if (filters == null) {
filters = new FiltersVector();
}
filters.addFilter(filter, true);
logRetrieval.setFilters(filters);
}
use of com.cosylab.logging.engine.FiltersVector in project ACS by ACS-Community.
the class EngineFilteringTest method testAddFiltersVector.
/**
* Test adding a FiltersVector
*/
public void testAddFiltersVector() throws Exception {
// No filters defined: getFilters() return null
assertNull(engine.getFilters());
// Create a filter
Filter f = new ExactFilter(LogField.ENTRYTYPE, false, LogTypeHelper.INFO, false);
assertNotNull(f);
// Create and add another filter
Filter f2 = new ExactFilter(LogField.ENTRYTYPE, false, LogTypeHelper.DEBUG, false);
assertNotNull(f2);
// Setup the filters vector
FiltersVector filters = new FiltersVector();
assertNotNull(filters);
filters.addFilter(f, true);
filters.addFilter(f2, true);
// Set the filters
engine.setFilters(filters, false);
assertNotNull(engine.getFilters());
assertEquals(filters.size(), engine.getFilters().size());
// Append the filters
engine.setFilters(filters, true);
assertNotNull(engine.getFilters());
assertEquals(filters.size() * 2, engine.getFilters().size());
}
use of com.cosylab.logging.engine.FiltersVector 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();
}
use of com.cosylab.logging.engine.FiltersVector in project ACS by ACS-Community.
the class TablePopupMenu method filters.
/**
* Filters out or shows only the longs under the mouse pointer
* by settng a new filter in the table.
*
* @param out If <code>true</code> filters out logs
*/
private void filters(boolean out) {
// Clean the string from XML tags
if (this.textToCopy.startsWith("<html>")) {
this.textToCopy = this.textToCopy.substring(6, this.textToCopy.length());
if (this.textToCopy.endsWith("</html>")) {
this.textToCopy = this.textToCopy.substring(0, this.textToCopy.length() - 7);
}
}
int colModelIndex = table.convertColumnIndexToModel(col);
Comparable comparable = null;
if (LogField.values()[colModelIndex - 1].getType() == String.class) {
comparable = this.textToCopy;
} else if (LogField.values()[colModelIndex - 1].getType() == Integer.class) {
comparable = Integer.valueOf(this.textToCopy);
} else if (LogField.values()[colModelIndex - 1].getType() == LogTypeHelper.class) {
comparable = LogTypeHelper.fromLogTypeDescription(this.textToCopy);
} else if (LogField.values()[colModelIndex - 1].getType() == Long.class) {
// Timestamp
try {
comparable = Long.valueOf(IsoDateFormat.parseIsoTimestamp(this.textToCopy).getTime());
} catch (Throwable t) {
System.err.println("Error parsing date " + this.textToCopy + ": " + t.getMessage());
t.printStackTrace(System.err);
return;
}
}
FiltersVector newFilterVector = new FiltersVector();
try {
ExactFilter newFilter = new ExactFilter(LogField.values()[colModelIndex - 1], false, comparable, out);
newFilterVector.addFilter(newFilter, true);
} catch (Throwable t) {
System.err.println("Error creating filter " + t.getMessage());
t.printStackTrace(System.err);
}
table.setFilters(newFilterVector, true);
loggingClient.setTableFilterLbl();
}
Aggregations