org.apache.nifi.logging.LogLevel Java Examples

The following examples show how to use org.apache.nifi.logging.LogLevel. 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: SimpleProcessLogger.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg) {
    switch (level) {
        case DEBUG:
            debug(msg);
            break;
        case ERROR:
        case FATAL:
            error(msg);
            break;
        case INFO:
            info(msg);
            break;
        case TRACE:
            trace(msg);
            break;
        case WARN:
            warn(msg);
            break;
    }
}
 
Example #2
Source File: MockComponentLog.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Throwable t) {
    switch (level) {
        case DEBUG:
            debug(msg, t);
            break;
        case ERROR:
        case FATAL:
            error(msg, t);
            break;
        case INFO:
            info(msg, t);
            break;
        case TRACE:
            trace(msg, t);
            break;
        case WARN:
            warn(msg, t);
            break;
    }
}
 
Example #3
Source File: MockComponentLogger.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os, Throwable t) {
    switch (level) {
        case DEBUG:
            debug(msg, os, t);
            break;
        case ERROR:
        case FATAL:
            error(msg, os, t);
            break;
        case INFO:
            info(msg, os, t);
            break;
        case TRACE:
            trace(msg, os, t);
            break;
        case WARN:
            warn(msg, os, t);
            break;
    }
}
 
Example #4
Source File: MockComponentLog.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os, Throwable t) {
    switch (level) {
        case DEBUG:
            debug(msg, os, t);
            break;
        case ERROR:
        case FATAL:
            error(msg, os, t);
            break;
        case INFO:
            info(msg, os, t);
            break;
        case TRACE:
            trace(msg, os, t);
            break;
        case WARN:
            warn(msg, os, t);
            break;
    }
}
 
Example #5
Source File: MockComponentLog.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg) {
    switch (level) {
        case DEBUG:
            debug(msg);
            break;
        case ERROR:
        case FATAL:
            error(msg);
            break;
        case INFO:
            info(msg);
            break;
        case TRACE:
            trace(msg);
            break;
        case WARN:
            warn(msg);
            break;
    }
}
 
Example #6
Source File: SimpleProcessLogger.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Throwable t) {
    switch (level) {
        case DEBUG:
            debug(msg, t);
            break;
        case ERROR:
        case FATAL:
            error(msg, t);
            break;
        case INFO:
            info(msg, t);
            break;
        case TRACE:
            trace(msg, t);
            break;
        case WARN:
            warn(msg, t);
            break;
    }
}
 
Example #7
Source File: MockComponentLogger.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os) {
    switch (level) {
        case DEBUG:
            debug(msg, os);
            break;
        case ERROR:
        case FATAL:
            error(msg, os);
            break;
        case INFO:
            info(msg, os);
            break;
        case TRACE:
            trace(msg, os);
            break;
        case WARN:
            warn(msg, os);
            break;
    }
}
 
Example #8
Source File: MockComponentLogger.java    From nifi-minifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os, Throwable t) {
    switch (level) {
        case DEBUG:
            debug(msg, os, t);
            break;
        case ERROR:
        case FATAL:
            error(msg, os, t);
            break;
        case INFO:
            info(msg, os, t);
            break;
        case TRACE:
            trace(msg, os, t);
            break;
        case WARN:
            warn(msg, os, t);
            break;
    }
}
 
Example #9
Source File: MockComponentLogger.java    From nifi-minifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os) {
    switch (level) {
        case DEBUG:
            debug(msg, os);
            break;
        case ERROR:
        case FATAL:
            error(msg, os);
            break;
        case INFO:
            info(msg, os);
            break;
        case TRACE:
            trace(msg, os);
            break;
        case WARN:
            warn(msg, os);
            break;
    }
}
 
Example #10
Source File: SLF4JComponentLog.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os) {
    switch (level) {
        case DEBUG:
            debug(msg, os);
            break;
        case ERROR:
        case FATAL:
            error(msg, os);
            break;
        case INFO:
            info(msg, os);
            break;
        case TRACE:
            trace(msg, os);
            break;
        case WARN:
            warn(msg, os);
            break;
    }
}
 
Example #11
Source File: MockComponentLogger.java    From nifi-minifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Throwable t) {
    switch (level) {
        case DEBUG:
            debug(msg, t);
            break;
        case ERROR:
        case FATAL:
            error(msg, t);
            break;
        case INFO:
            info(msg, t);
            break;
        case TRACE:
            trace(msg, t);
            break;
        case WARN:
            warn(msg, t);
            break;
    }
}
 
Example #12
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 #13
Source File: MockComponentLog.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os) {
    switch (level) {
        case DEBUG:
            debug(msg, os);
            break;
        case ERROR:
        case FATAL:
            error(msg, os);
            break;
        case INFO:
            info(msg, os);
            break;
        case TRACE:
            trace(msg, os);
            break;
        case WARN:
            warn(msg, os);
            break;
    }
}
 
Example #14
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();
    }
}
 
Example #15
Source File: MockComponentLog.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void log(LogLevel level, String msg) {
    switch (level) {
        case WARN:
            warn(msg);
            break;
        case DEBUG:
            debug(msg);
            break;
        case INFO:
            info(msg);
            break;
        case ERROR:
            error(msg);
            break;
        case TRACE:
            trace(msg);
            break;
        case FATAL:
            error(msg);
            break;
        case NONE:
            info(msg);
            break;
    }
}
 
Example #16
Source File: StatusLoggerTest.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Test
public void TestInfoException() throws IOException {
    IOException ioException = new IOException("This is an expected test exception");
    Mockito.when(queryableStatusAggregator.statusReport(MOCK_QUERY)).thenThrow(ioException);

    statusLogger.initialize(getProperties(LogLevel.INFO), queryableStatusAggregator);
    statusLogger.start();

    verify(logger, Mockito.timeout(300).atLeastOnce()).info(ENCOUNTERED_IO_EXCEPTION, ioException);
}
 
Example #17
Source File: StatusLoggerTest.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Test
public void TestDebugException() throws IOException {
    IOException ioException = new IOException("This is an expected test exception");
    Mockito.when(queryableStatusAggregator.statusReport(MOCK_QUERY)).thenThrow(ioException);

    statusLogger.initialize(getProperties(LogLevel.DEBUG), queryableStatusAggregator);
    statusLogger.start();

    verify(logger, Mockito.timeout(300).atLeastOnce()).debug(ENCOUNTERED_IO_EXCEPTION, ioException);
}
 
Example #18
Source File: TerminationAwareLogger.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Throwable t) {
    if (isTerminated()) {
        logger.debug(getMessage(msg, level), t);
        return;
    }

    logger.log(level, msg, t);
}
 
Example #19
Source File: TestFlowController.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessorDefaultSettingsAnnotation() throws ProcessorInstantiationException {
    ProcessorNode p_settings = controller.createProcessor(DummySettingsProcessor.class.getName(),"1234-SettingsProcessor");
    assertEquals("5 sec",p_settings.getYieldPeriod());
    assertEquals("1 min",p_settings.getPenalizationPeriod());
    assertEquals(LogLevel.DEBUG,p_settings.getBulletinLevel());
    assertEquals(1,p_settings.getMaxConcurrentTasks());
    assertEquals(SchedulingStrategy.TIMER_DRIVEN,p_settings.getSchedulingStrategy());
    assertEquals("0 sec",p_settings.getSchedulingPeriod());
}
 
Example #20
Source File: LogHandler.java    From nifi with Apache License 2.0 5 votes vote down vote up
private LogLevel getLogLevel(String logLevel, LogLevel defaultLevel) {
    LogLevel level;
    if (StringUtils.isNotEmpty(logLevel)) {
        try {
            level = LogLevel.valueOf(logLevel.toUpperCase());
        } catch (IllegalArgumentException iea) {
            level = defaultLevel;
        }
    } else {
        level = defaultLevel;
    }
    return level;
}
 
Example #21
Source File: TerminationAwareLogger.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void log(LogLevel level, String msg, Object[] os, Throwable t) {
    if (isTerminated()) {
        logger.debug(getMessage(msg, level), os, t);
        return;
    }

    logger.log(level, msg, os, t);
}
 
Example #22
Source File: StandardLogRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void setObservationLevel(String observerIdentifier, LogLevel level) {
    writeLock.lock();
    try {
        final LogObserver observer = removeObserver(observerIdentifier);

        if (observer != null) {
            addObserver(observerIdentifier, level, observer);
        }
    } finally {
        writeLock.unlock();
    }
}
 
Example #23
Source File: SimpleProcessLogger.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void info(String msg) {
    if (!isInfoEnabled()) {
        return;
    }

    msg = "{} " + msg;
    final Object[] os = {component};

    logger.info(msg, os);
    logRepository.addLogMessage(LogLevel.INFO, msg, os);
}
 
Example #24
Source File: SimpleProcessLogger.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void info(String msg, Throwable t) {
    if (!isInfoEnabled()) {
        return;
    }

    msg = "{} " + msg;
    final Object[] os = {component, t.toString()};

    logger.info(msg, os);
    if (logger.isDebugEnabled()) {
        logger.info("", t);
    }
    logRepository.addLogMessage(LogLevel.INFO, msg, os, t);
}
 
Example #25
Source File: SimpleProcessLogger.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void debug(String msg, Object[] os) {
    if (!isDebugEnabled()) {
        return;
    }

    os = addProcessor(os);
    msg = "{} " + msg;

    logger.debug(msg, os);
    logRepository.addLogMessage(LogLevel.DEBUG, msg, os);
}
 
Example #26
Source File: SimpleProcessLogger.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void debug(String msg, Throwable t) {
    if (!isDebugEnabled()) {
        return;
    }

    msg = "{} " + msg;
    final Object[] os = {component};

    logger.debug(msg, os, t);
    logRepository.addLogMessage(LogLevel.DEBUG, msg, os, t);
}
 
Example #27
Source File: SimpleProcessLogger.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void error(String msg, Object[] os, Throwable t) {
    if (!isErrorEnabled()) {
        return;
    }

    os = addProcessorAndThrowable(os, t);
    msg = "{} " + msg + ": {}";

    logger.error(msg, os);
    logger.error("", t);
    logRepository.addLogMessage(LogLevel.ERROR, msg, os, t);
}
 
Example #28
Source File: SimpleProcessLogger.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void error(String msg, Object[] os) {
    if (!isErrorEnabled()) {
        return;
    }

    if (lastArgIsException(os)) {
        error(msg, translateException(os), (Throwable) os[os.length - 1]);
    } else {
        os = addProcessor(os);
        msg = "{} " + msg;
        logger.error(msg, os);
        logRepository.addLogMessage(LogLevel.ERROR, msg, os);
    }
}
 
Example #29
Source File: SimpleProcessLogger.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void debug(String msg, Throwable t) {
    if (!isDebugEnabled()) {
        return;
    }

    msg = "{} " + msg;
    final Object[] os = {component};

    logger.debug(msg, os, t);
    logRepository.addLogMessage(LogLevel.DEBUG, msg, os, t);
}
 
Example #30
Source File: StatusLoggerTest.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testFailedInitDueToNoQuery(){
    Properties properties = new Properties();
    properties.setProperty(REPORT_PERIOD_KEY, "100");
    properties.setProperty(LOGGING_LEVEL_KEY, LogLevel.INFO.name());

    statusLogger.initialize(properties, queryableStatusAggregator);
}