Search in sources :

Example 26 with ILogEntry

use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.

the class LogEntryTable method zoom.

/**
	 * Zoom over the selected logs.
	 * <P>
	 * The zoom consists of loading all the logs in the time interval
	 * defined by the selected logs.
	 * The zoom is delegated to the <code>ZoomManager</code>.
	 * 
	 *  @see {@link ZoomManager}
	 */
public void zoom() {
    if (getSelectedRowCount() <= 1) {
        return;
    }
    int[] indexes = getSelectedRows();
    long startDate = Long.MAX_VALUE;
    long endDate = 0;
    zoomTotFiles = 0;
    System.out.println("Keys " + indexes.length);
    for (int i : indexes) {
        ILogEntry log = getLCModel().getVisibleLogEntry(convertRowIndexToModel(i));
        long time = ((Long) log.getField(LogField.TIMESTAMP)).longValue();
        if (time < startDate) {
            startDate = time;
        }
        if (time > endDate) {
            endDate = time;
        }
    }
    String startDateStr = IsoDateFormat.formatDate(new Date(startDate));
    String endDateStr = IsoDateFormat.formatDate(new Date(endDate));
    System.out.println("Zooming from " + startDateStr + " to " + endDateStr);
    try {
        loggingClient.getZoomManager().zoom(startDateStr, endDateStr, loggingClient, this, loggingClient);
    } catch (Throwable t) {
        JOptionPane.showMessageDialog(loggingClient, "Error while loading logs.\n" + t.getMessage(), "Zoom error", JOptionPane.ERROR_MESSAGE);
    }
    if (zoomProgressMonitor != null) {
        zoomProgressMonitor.close();
        zoomProgressMonitor = null;
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) Date(java.util.Date)

Example 27 with ILogEntry

use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.

the class TablePopupMenu method show.

/**
	 * Show the popup menu
	 * 
	 * @param invoker the component in whose space the popup menu is to appear
	 * @param x the x coordinate in invoker's coordinate space at which the popup menu is to be displayed
	 * @param y the y coordinate in invoker's coordinate space at which the popup menu is to be displayed
	 * @param row The row below the pointer
	 * @param col The col below the pointer
	 * @param txt The text below the pointer
	 */
public void show(Component invoker, int x, int y, int row, int col, String txt) {
    this.row = row;
    this.col = col;
    this.textToCopy = txt;
    // Hide the unneeded buttons
    boolean singleLineSelected = selectionModel.getMinSelectionIndex() == selectionModel.getMaxSelectionIndex();
    if (singleLineSelected) {
        ILogEntry selectedLog = model.getVisibleLogEntry(table.convertRowIndexToModel(row));
        stackId = (String) selectedLog.getField(LogField.STACKID);
        showErrorStack.setEnabled(stackId != null && !stackId.isEmpty());
    } else {
        stackId = null;
        showErrorStack.setEnabled(false);
    }
    addUserInfo.setEnabled(singleLineSelected);
    copyClipboard.setEnabled(true);
    saveSelected.setEnabled(true);
    int colModelIndex = table.convertColumnIndexToModel(col);
    quickFiltersMenu.setEnabled(colModelIndex > 0);
    // Disable the menu items if the test is null or empty
    if (textToCopy == null || textToCopy.length() == 0) {
        copyClipboard.setEnabled(false);
        return;
    }
    // Check if the system clipboard is available
    // and eventually disable the menu item
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        try {
            sm.checkSystemClipboardAccess();
        } catch (Exception e) {
            copyClipboard.setEnabled(false);
        }
    }
    // Disable the zoom if only one line is selected
    zoomOverSelected.setEnabled(!singleLineSelected && loggingClient.getZoomManager().isAvailable());
    show(invoker, x, y);
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 28 with ILogEntry

use of com.cosylab.logging.engine.log.ILogEntry 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 29 with ILogEntry

use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.

the class LogProcessor method reduce.

/**
	 * Reduce the logs by applying the reduction rules.
	 * 
	 * @param logs The logs to reduce
	 */
public void reduce(List<ILogEntry> logs) {
    for (int t = 0; t < logs.size(); t++) {
        // This is the log that "could" reduce other logs
        ILogEntry log = logs.get(t);
        if (log == null) {
            // Should never happen
            continue;
        }
        ReductionRule rule;
        try {
            rule = new SourceAntennaRule(log);
            if (!rule.isReducible()) {
                rule = new AntennaRule(log);
                if (!rule.isReducible()) {
                    continue;
                }
            }
        } catch (Throwable th) {
            System.out.println("LogProcessor: error instantiating a Reduction rule: " + th.getMessage());
            System.out.println("Problematic log: " + log.toString());
            th.printStackTrace();
            continue;
        }
        // Now scan the remaining logs in the vector, apply the rule
        // and if it is the case remove the reduced log.
        int j = t + 1;
        while (j < logs.size()) {
            ILogEntry reducibleLog = logs.get(j);
            if (rule.applyRule(reducibleLog)) {
                // The log has to be deleted from the vector
                logs.remove(j);
                continue;
            }
            j++;
        }
        if (rule.isReducingLogs()) {
            // Create the new log with the message
            ILogEntry newLog = rule.getReducedLog();
            logs.set(t, newLog);
        }
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry)

Example 30 with ILogEntry

use of com.cosylab.logging.engine.log.ILogEntry 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

ILogEntry (com.cosylab.logging.engine.log.ILogEntry)85 Vector (java.util.Vector)15 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)11 Date (java.util.Date)11 IsoDateFormat (alma.acs.util.IsoDateFormat)9 LogCacheException (com.cosylab.logging.client.cache.LogCacheException)9 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)9 SimpleDateFormat (java.text.SimpleDateFormat)9 FieldPosition (java.text.FieldPosition)8 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)7 LogEntry (com.cosylab.logging.engine.log.LogEntry)6 ParserTypes (alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes)5 LogBufferedFileCache (com.cosylab.logging.client.cache.LogBufferedFileCache)5 LogFileCache (com.cosylab.logging.client.cache.LogFileCache)5 Random (java.util.Random)5 IOHelper (alma.acs.logging.engine.io.IOHelper)4 LogCache (com.cosylab.logging.client.cache.LogCache)4 IOException (java.io.IOException)4 ILogMap (com.cosylab.logging.client.cache.ILogMap)3 LogField (com.cosylab.logging.engine.log.LogField)3