Search in sources :

Example 6 with FiltersVector

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);
}
Also used : FiltersVector(com.cosylab.logging.engine.FiltersVector) CheckListTableEntry(alma.acs.gui.widgets.CheckList.CheckListTableEntry)

Example 7 with FiltersVector

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);
}
Also used : FiltersVector(com.cosylab.logging.engine.FiltersVector)

Example 8 with FiltersVector

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());
}
Also used : ExactFilter(com.cosylab.logging.engine.ExactFilter) ExactFilter(com.cosylab.logging.engine.ExactFilter) Filter(com.cosylab.logging.engine.Filter) FiltersVector(com.cosylab.logging.engine.FiltersVector)

Example 9 with FiltersVector

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();
}
Also used : FiltersVector(com.cosylab.logging.engine.FiltersVector) LogEntry(com.cosylab.logging.engine.log.LogEntry)

Example 10 with FiltersVector

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();
}
Also used : ExactFilter(com.cosylab.logging.engine.ExactFilter) FiltersVector(com.cosylab.logging.engine.FiltersVector)

Aggregations

FiltersVector (com.cosylab.logging.engine.FiltersVector)12 CheckListTableEntry (alma.acs.gui.widgets.CheckList.CheckListTableEntry)2 ExactFilter (com.cosylab.logging.engine.ExactFilter)2 Filter (com.cosylab.logging.engine.Filter)2 Filterable (com.cosylab.logging.engine.Filterable)2 FilterChooserDialog (com.cosylab.logging.settings.FilterChooserDialog)2 File (java.io.File)2 InvalidFilterConstraintException (com.cosylab.logging.engine.InvalidFilterConstraintException)1 MinMaxFilter (com.cosylab.logging.engine.MinMaxFilter)1 LogEntry (com.cosylab.logging.engine.log.LogEntry)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 JFileChooser (javax.swing.JFileChooser)1