use of org.eclipse.equinox.log.LogFilter in project rt.equinox.framework by eclipse.
the class OrderedExecutor method logPrivileged.
void logPrivileged(Bundle bundle, String name, StackTraceElement stackTraceElement, Object context, LogLevel logLevelEnum, int level, String message, Throwable exception) {
LogEntry logEntry = new ExtendedLogEntryImpl(bundle, name, stackTraceElement, context, logLevelEnum, level, message, exception);
storeEntry(logEntry);
ArrayMap<LogListener, Object[]> listenersCopy;
listenersLock.readLock().lock();
try {
listenersCopy = listeners;
} finally {
listenersLock.readLock().unlock();
}
try {
if (incrementNestedCount() >= MAX_RECURSIONS)
return;
int size = listenersCopy.size();
for (int i = 0; i < size; i++) {
Object[] listenerObjects = listenersCopy.getValue(i);
LogFilter filter = (LogFilter) listenerObjects[0];
if (safeIsLoggable(filter, bundle, name, level)) {
LogListener listener = listenersCopy.getKey(i);
OrderedTaskQueue orderedTaskQueue = (OrderedTaskQueue) listenerObjects[1];
if (orderedTaskQueue != null) {
orderedTaskQueue.execute(new LogTask(logEntry, listener), size);
} else {
// log synchronously
safeLogged(listener, logEntry);
}
}
}
} finally {
decrementNestedCount();
}
}
use of org.eclipse.equinox.log.LogFilter in project rt.equinox.framework by eclipse.
the class OrderedExecutor method recalculateFilters.
private void recalculateFilters(ArrayMap<LogListener, Object[]> listenersCopy) {
List<LogFilter> filtersList = new ArrayList<>();
int size = listenersCopy.size();
for (int i = 0; i < size; i++) {
Object[] listenerObjects = listenersCopy.getValue(i);
LogFilter filter = (LogFilter) listenerObjects[0];
if (filter == NULL_LOGGER_FILTER) {
filters = ALWAYS_LOG;
return;
}
filtersList.add(filter);
}
if (filtersList.isEmpty())
filters = null;
filters = filtersList.toArray(new LogFilter[filtersList.size()]);
}
use of org.eclipse.equinox.log.LogFilter in project rt.equinox.framework by eclipse.
the class OrderedExecutor method isLoggablePrivileged.
boolean isLoggablePrivileged(Bundle bundle, String name, int level) {
LogFilter[] filtersCopy;
listenersLock.readLock().lock();
try {
filtersCopy = filters;
} finally {
listenersLock.readLock().unlock();
}
try {
if (incrementNestedCount() == MAX_RECURSIONS)
return false;
if (filtersCopy == null)
return false;
if (filtersCopy == ALWAYS_LOG)
return true;
int filtersLength = filtersCopy.length;
for (int i = 0; i < filtersLength; i++) {
LogFilter filter = filtersCopy[i];
if (safeIsLoggable(filter, bundle, name, level))
return true;
}
} finally {
decrementNestedCount();
}
return false;
}
use of org.eclipse.equinox.log.LogFilter in project rt.equinox.framework by eclipse.
the class ExtendedLogReaderServiceTest method testaddFilteredListenerTwice.
public void testaddFilteredListenerTwice() throws Exception {
TestListener listener = new TestListener();
reader.addLogListener(listener, new LogFilter() {
public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
return false;
}
});
if (log.isLoggable(LogService.LOG_INFO))
fail();
reader.addLogListener(listener, new LogFilter() {
public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
return true;
}
});
synchronized (listener) {
log.log(LogService.LOG_INFO, "info");
listener.waitForLogEntry();
}
assertTrue(listener.getEntryX().getLevel() == LogService.LOG_INFO);
}
use of org.eclipse.equinox.log.LogFilter in project rt.equinox.framework by eclipse.
the class ExtendedLogReaderServiceTest method testaddFilteredListener.
public void testaddFilteredListener() throws Exception {
TestListener listener = new TestListener();
reader.addLogListener(listener, new LogFilter() {
public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
return true;
}
});
synchronized (listener) {
log.log(LogService.LOG_INFO, "info");
listener.waitForLogEntry();
}
assertTrue(listener.getEntryX().getLevel() == LogService.LOG_INFO);
}
Aggregations