Java Code Examples for org.apache.nifi.logging.LogLevel#values()

The following examples show how to use org.apache.nifi.logging.LogLevel#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardLogRepository.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public LogLevel getObservationLevel(String observerIdentifier) {
    readLock.lock();
    try {
        // ensure observer exists
        if (!observerLookup.containsKey(observerIdentifier)) {
            throw new IllegalStateException("The specified observer identifier does not exist.");
        }

        final LogObserver observer = observerLookup.get(observerIdentifier);
        for (final LogLevel logLevel : LogLevel.values()) {
            final Collection<LogObserver> levelObservers = observers.get(logLevel);
            if (levelObservers != null && levelObservers.contains(observer)) {
                return logLevel;
            }
        }

        // at this point, the observer should have been found
        throw new IllegalStateException("The specified observer identifier does not exist.");
    } finally {
        readLock.unlock();
    }
}
 
Example 2
Source File: StandardLogRepository.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void addObserver(final String observerIdentifier, final LogLevel minimumLevel, final LogObserver observer) {
    writeLock.lock();
    try {
        // ensure observer does not exists
        if (observerLookup.containsKey(observerIdentifier)) {
            throw new IllegalStateException("The specified observer identifier already exists.");
        }

        final LogLevel[] allLevels = LogLevel.values();
        for (int i = minimumLevel.ordinal(); i < allLevels.length; i++) {
            Collection<LogObserver> collection = observers.get(allLevels[i]);
            if (collection == null) {
                collection = new ArrayList<>();
                observers.put(allLevels[i], collection);
            }
            collection.add(observer);
        }
        observerLookup.put(observerIdentifier, observer);
    } finally {
        writeLock.unlock();
    }
}
 
Example 3
Source File: StandardLogRepository.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public LogLevel getObservationLevel(String observerIdentifier) {
    readLock.lock();
    try {
        // ensure observer exists
        if (!observerLookup.containsKey(observerIdentifier)) {
            throw new IllegalStateException("The specified observer identifier does not exist.");
        }

        final LogObserver observer = observerLookup.get(observerIdentifier);
        for (final LogLevel logLevel : LogLevel.values()) {
            final Collection<LogObserver> levelObservers = observers.get(logLevel);
            if (levelObservers != null && levelObservers.contains(observer)) {
                return logLevel;
            }
        }

        // at this point, the LogLevel must be NONE since we don't register observers for NONE
        return LogLevel.NONE;
    } finally {
        readLock.unlock();
    }
}
 
Example 4
Source File: StandardLogRepository.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void addObserver(final String observerIdentifier, final LogLevel minimumLevel, final LogObserver observer) {
    writeLock.lock();
    try {
        // ensure observer does not exists
        if (observerLookup.containsKey(observerIdentifier)) {
            throw new IllegalStateException("The specified observer identifier (" + observerIdentifier + ") already exists.");
        }

        final LogLevel[] allLevels = LogLevel.values();
        for (int i = minimumLevel.ordinal(); i < allLevels.length; i++) {
            // no need to register an observer for NONE since that level will never be logged to by a component
            if (i != LogLevel.NONE.ordinal()) {
                Collection<LogObserver> collection = observers.get(allLevels[i]);
                if (collection == null) {
                    collection = new ArrayList<>();
                    observers.put(allLevels[i], collection);
                }
                collection.add(observer);
            }
        }
        observerLookup.put(observerIdentifier, observer);
    } finally {
        writeLock.unlock();
    }
}