Search in sources :

Example 1 with OrderedTaskQueue

use of org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue 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();
    }
}
Also used : SynchronousLogListener(org.eclipse.equinox.log.SynchronousLogListener) LogListener(org.osgi.service.log.LogListener) SynchronousLogListener(org.eclipse.equinox.log.SynchronousLogListener) OrderedTaskQueue(org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue) ArrayMap(org.eclipse.osgi.framework.util.ArrayMap)

Example 2 with OrderedTaskQueue

use of org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue 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();
    }
}
Also used : SynchronousLogListener(org.eclipse.equinox.log.SynchronousLogListener) LogListener(org.osgi.service.log.LogListener) OrderedTaskQueue(org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue) LogEntry(org.osgi.service.log.LogEntry) LogFilter(org.eclipse.equinox.log.LogFilter)

Aggregations

SynchronousLogListener (org.eclipse.equinox.log.SynchronousLogListener)2 OrderedTaskQueue (org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue)2 LogListener (org.osgi.service.log.LogListener)2 LogFilter (org.eclipse.equinox.log.LogFilter)1 ArrayMap (org.eclipse.osgi.framework.util.ArrayMap)1 LogEntry (org.osgi.service.log.LogEntry)1