Search in sources :

Example 6 with LogTypeHelper

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));
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) RegExpFilter(com.cosylab.logging.engine.RegExpFilter) ExactFilter(com.cosylab.logging.engine.ExactFilter) MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) Filter(com.cosylab.logging.engine.Filter) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) Date(java.util.Date)

Example 7 with LogTypeHelper

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));
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) RegExpFilter(com.cosylab.logging.engine.RegExpFilter) ExactFilter(com.cosylab.logging.engine.ExactFilter) MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) Filter(com.cosylab.logging.engine.Filter) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) Date(java.util.Date)

Example 8 with LogTypeHelper

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));
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) RegExpFilter(com.cosylab.logging.engine.RegExpFilter) ExactFilter(com.cosylab.logging.engine.ExactFilter) MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) Filter(com.cosylab.logging.engine.Filter) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) Date(java.util.Date)

Example 9 with LogTypeHelper

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

Example 10 with LogTypeHelper

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

Aggregations

LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)30 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)8 Date (java.util.Date)6 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)5 JComboBox (javax.swing.JComboBox)5 ExactFilter (com.cosylab.logging.engine.ExactFilter)4 MinMaxFilter (com.cosylab.logging.engine.MinMaxFilter)4 LogTypeRenderer (com.cosylab.logging.settings.LogTypeRenderer)4 Filter (com.cosylab.logging.engine.Filter)3 RegExpFilter (com.cosylab.logging.engine.RegExpFilter)3 LogEntry (com.cosylab.logging.engine.log.LogEntry)3 SystemException (org.omg.CORBA.SystemException)3 LogLevels (alma.Logging.LoggingConfigurablePackage.LogLevels)2 LogLvlSelNotSupportedException (alma.acs.gui.loglevel.LogLvlSelNotSupportedException)2 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)2 IsoDateFormat (alma.acs.util.IsoDateFormat)2 GridBagLayout (java.awt.GridBagLayout)2 Point (java.awt.Point)2 FieldPosition (java.text.FieldPosition)2 SimpleDateFormat (java.text.SimpleDateFormat)2