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;
}
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("&", "&");
value = value.replaceAll("'", "'");
value = value.replaceAll("`", "'");
value = value.replaceAll("\"", """);
value = value.replaceAll("<", "<");
value = value.replaceAll(">", ">");
name = name.replaceAll("&", "&");
name = name.replaceAll("'", "'");
name = name.replaceAll("`", "'");
name = name.replaceAll("\"", """);
name = name.replaceAll("<", "<");
name = name.replaceAll(">", ">");
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);
}
}
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;
}
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));
}
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);
}
}
Aggregations