Search in sources :

Example 56 with ILogEntry

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

the class LogEntryTable method getExtraInfo.

/**
	 * Insert the method's description here.
	 * Creation date: (2/7/02 3:52:36 PM)
	 * @return java.lang.String
	 */
public org.w3c.dom.Node getExtraInfo() {
    //	String noInfoString = ;
    //	org.w3c.dom.Node nn = new org.w3c.dom.Node.;
    //	DataNode dn = new DataNode(null);
    //	dn.setNodeValue("No additional information");
    int index = getSelectedRow();
    if (index < 0)
        return null;
    ILogEntry additionalInfo = getLCModel().getVisibleLogEntry(index);
    if (!additionalInfo.hasDatas()) {
        return null;
    }
    //additionalInfo.getDatas().item(0);
    return null;
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry)

Example 57 with ILogEntry

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

the class TablePopupMenu method actionPerformed.

/**
	 * Handle the events from the menu
	 * 
	 * @param e The event
	 */
public void actionPerformed(ActionEvent e) {
    if (textToCopy == null) {
        return;
    }
    if (e.getSource() == copyClipXml) {
        copyToClipboard(new XMLConverter());
    } else if (e.getSource() == copyClipTxt) {
        copyToClipboard(new TextConverter(null));
    } else if (e.getSource() == copyClipTwikiTable) {
        copyToClipboard(new TwikiTableConverter(null));
    } else if (e.getSource() == copyClipCSV) {
        copyToClipboard(new CSVConverter());
    } else if (e.getSource() == addUserInfo) {
        // Show the dialog
        UserInfoDlg dlg = new UserInfoDlg();
        if (dlg.okPressed()) {
            String name = dlg.getInfoName();
            String value = dlg.getInfo();
            // Replace some chars potentially dangerous for xml
            value = value.replaceAll("&", "&amp;");
            value = value.replaceAll("'", "&apos;");
            value = value.replaceAll("`", "&apos;");
            value = value.replaceAll("\"", "&quot;");
            value = value.replaceAll("<", "&lt;");
            value = value.replaceAll(">", "&gt;");
            name = name.replaceAll("&", "&amp;");
            name = name.replaceAll("'", "&apos;");
            name = name.replaceAll("`", "&apos;");
            name = name.replaceAll("\"", "&quot;");
            name = name.replaceAll("<", "&lt;");
            name = name.replaceAll(">", "&gt;");
            ILogEntry logEntry = model.getVisibleLogEntry(table.convertRowIndexToModel(row));
            logEntry.addData(name, value);
            model.replaceLog(table.convertRowIndexToModel(row), logEntry);
            LogTableDataModel tableModel = (LogTableDataModel) table.getModel();
            tableModel.fireTableRowsUpdated(table.convertRowIndexToModel(row), table.convertRowIndexToModel(row));
            table.setRowSelectionInterval(row, row);
            loggingClient.setLogDetailContent(logEntry);
        }
    } else if (e.getSource() == saveSelectedAsCSV) {
        saveSelectedLogs(new CSVConverter(), saveCsvIcon, "txt");
    } else if (e.getSource() == saveSelectedAsText) {
        saveSelectedLogs(new TextConverter(null), saveTextIcon, "txt");
    } else if (e.getSource() == saveSelectedAsTwiki) {
        saveSelectedLogs(new TwikiTableConverter(null), saveTwikiTableIcon, "txt");
    } else if (e.getSource() == saveSelectedAsXML) {
        saveSelectedLogs(new XMLConverter(), saveXmlIcon, "xml");
    } else if (e.getSource() == showErrorStack) {
        if (stackId != null && !stackId.isEmpty()) {
            loggingClient.addErrorTab(stackId);
        }
    } else if (e.getSource() == zoomOverSelected) {
        Thread t = new Thread(new Runnable() {

            public void run() {
                table.zoom();
            }
        });
        t.setDaemon(true);
        t.setName("TablePopupMenu.actionPerformed.Zoom");
        t.start();
    } else if (e.getSource() == showsOnlyMI || e.getSource() == filtersOutMI) {
        filters(e.getSource() == filtersOutMI);
    } else {
        System.err.println("Unhandled event " + e);
    }
}
Also used : TwikiTableConverter(alma.acs.logging.tools.TwikiTableConverter) CSVConverter(alma.acs.logging.tools.CSVConverter) ILogEntry(com.cosylab.logging.engine.log.ILogEntry) XMLConverter(alma.acs.logging.tools.XMLConverter) UserInfoDlg(com.cosylab.logging.settings.UserInfoDlg) TextConverter(alma.acs.logging.tools.TextConverter)

Example 58 with ILogEntry

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

the class CacheTest method fillCache.

/**
	 * Fill the cache with dynamically generated logs
	 * The number of logs inserted in the list is greater than the 
	 * memory cache size to stress the disk cache also.
	 * 
	 * @return The number of logs inserted in the cache
	 * 
	 * @throws Exception
	 */
private long fillCache() throws Exception {
    ACSLogParser parser = ACSLogParserFactory.getParser();
    String logMsg = "Test log nr. ";
    // Yesterday
    long now = Calendar.getInstance().getTimeInMillis() - 1000 * 60 * 60 * 24;
    SimpleDateFormat df = new IsoDateFormat();
    cache.clear();
    long logToInsert = 2 * cache.getCacheSize();
    for (int t = 0; t < logToInsert; t++) {
        Date dt = new Date(now + t * 1000);
        StringBuffer dateSB = new StringBuffer();
        FieldPosition pos = new FieldPosition(0);
        df.format(dt, dateSB, pos);
        String newLogMsg = logMsg + "t";
        StringBuilder logStr = new StringBuilder("<Info TimeStamp=\"");
        logStr.append(dateSB.toString());
        logStr.append("\" Routine=\"CacheTest::testGet\" Host=\"this\" Process=\"test\" Thread=\"main\" Context=\"\"><![CDATA[");
        logStr.append(newLogMsg);
        logStr.append("]]></Info>");
        ILogEntry newLog = parser.parse(logStr.toString());
        cache.add(newLog);
    }
    return logToInsert;
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) ACSLogParser(alma.acs.logging.engine.parser.ACSLogParser) IsoDateFormat(alma.acs.util.IsoDateFormat) FieldPosition(java.text.FieldPosition) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 59 with ILogEntry

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

the class CacheTest method testReplace.

/**
	 * Test the replacement of a log
	 *
	 */
public void testReplace() throws Exception {
    ACSLogParser parser = ACSLogParserFactory.getParser();
    String logMsg = "Replaced test log";
    String logStr = "<Info TimeStamp=\"2005-11-29T16:00:00.000\" Routine=\"CacheTest::testReplace\" Host=\"this\" Process=\"test\" Thread=\"main\" Context=\"\"><![CDATA[" + logMsg + "]]></Info>";
    ILogEntry newLog = parser.parse(logStr);
    // Replace the first log
    cache.replaceLog(0, newLog);
    assertEquals("Error replacing log " + 0, logMsg, (String) cache.getLog(0).getField(LogField.LOGMESSAGE));
    // Replace the last log
    cache.replaceLog(cache.getSize() - 1, newLog);
    assertEquals("Error replacing log " + (cache.getSize() - 1), logMsg, (String) cache.getLog(cache.getSize() - 1).getField(LogField.LOGMESSAGE));
    // Replace a log in the middle
    int pos = cache.getSize() / 2;
    cache.replaceLog(pos, newLog);
    assertEquals("Error replacing log " + pos, logMsg, (String) cache.getLog(pos).getField(LogField.LOGMESSAGE));
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) ACSLogParser(alma.acs.logging.engine.parser.ACSLogParser)

Example 60 with ILogEntry

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

the class CacheTest method testKeySet.

/**
	 * Test the keys returned by keyset
	 * 
	 * @throws Exception
	 */
public void testKeySet() throws Exception {
    // Check the number of the keys
    assertEquals("The logs in cache and the number of keys differ", cache.getSize(), cache.keySet().size());
    // Get all the logs with the keys returned by keySet
    Set<Integer> keys = cache.keySet();
    for (Integer key : keys) {
        ILogEntry log = cache.getLog(key);
        assertNotNull("Got a null log!", log);
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry)

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