use of org.eclipse.equinox.log.SynchronousLogListener in project rt.equinox.framework by eclipse.
the class OrderedExecutor method addLogListener.
void addLogListener(LogListener listener, LogFilter filter) {
listenersLock.writeLock().lock();
try {
ArrayMap<LogListener, Object[]> listenersCopy = new ArrayMap<>(listeners.getKeys(), listeners.getValues());
Object[] listenerObjects = listenersCopy.get(listener);
if (listenerObjects == null) {
// Only create a task queue for non-SynchronousLogListeners
OrderedTaskQueue taskQueue = (listener instanceof SynchronousLogListener) ? null : executor.createQueue();
listenerObjects = new Object[] { filter, taskQueue };
} else if (filter != listenerObjects[0]) {
// update the filter
listenerObjects[0] = filter;
}
listenersCopy.put(listener, listenerObjects);
recalculateFilters(listenersCopy);
listeners = listenersCopy;
} finally {
listenersLock.writeLock().unlock();
}
}
use of org.eclipse.equinox.log.SynchronousLogListener in project rt.equinox.framework by eclipse.
the class ExtendedLogReaderServiceTest method testSynchronousLogListener.
public void testSynchronousLogListener() throws Exception {
final Thread loggerThread = Thread.currentThread();
called = false;
LogListener listener = new SynchronousLogListener() {
public void logged(LogEntry entry) {
assertTrue(Thread.currentThread() == loggerThread);
called = true;
}
};
reader.addLogListener(listener);
log.log(LogService.LOG_INFO, "info");
assertTrue(called);
}
use of org.eclipse.equinox.log.SynchronousLogListener in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testDebugLogOnGetURL.
public void testDebugLogOnGetURL() throws Exception {
Properties debugOptions = new Properties();
debugOptions.put("org.eclipse.osgi/debug/location", "true");
File debugOptionsFile = OSGiTestsActivator.getContext().getDataFile(getName() + ".options");
debugOptions.store(new FileOutputStream(debugOptionsFile), getName());
Map<String, String> fwkConfig = new HashMap<String, String>();
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true");
fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g");
fwkConfig.put(EquinoxConfiguration.PROP_DEBUG, debugOptionsFile.getAbsolutePath());
fwkConfig.put("eclipse.consoleLog", "true");
Equinox equinox = new Equinox(fwkConfig);
equinox.init();
try {
final List<LogEntry> logEntries = new ArrayList<LogEntry>();
LogReaderService logReaderService = getLogReaderService(equinox);
LogListener logListener = new SynchronousLogListener() {
@Override
public void logged(LogEntry entry) {
logEntries.add(entry);
}
};
logReaderService.addLogListener(logListener);
Map<String, Location> locations = getLocations(equinox);
Location userLocation = locations.get(Location.USER_FILTER);
Location instanceLocation = locations.get(Location.INSTANCE_FILTER);
assertNotNull("User locatoin is not null.", userLocation.getURL());
assertNotNull("Instance location is not null.", instanceLocation.getURL());
assertEquals("Wrong number of log entries", 2, logEntries.size());
} finally {
equinox.stop();
}
}
Aggregations