mirror of https://github.com/apache/nifi.git
NIFI-2158 : return 'true' for isXYZEnabled() for ComponentLog if either the slf4j logger has that level enabled or the bulletin repository does, instead of only checking if slf4j logger has it enabled
This closes #598
This commit is contained in:
parent
b7a584122d
commit
8f1202899b
|
@ -76,4 +76,12 @@ public interface LogRepository {
|
|||
* @return the current logger for the component
|
||||
*/
|
||||
ComponentLog getLogger();
|
||||
|
||||
boolean isDebugEnabled();
|
||||
|
||||
boolean isInfoEnabled();
|
||||
|
||||
boolean isWarnEnabled();
|
||||
|
||||
boolean isErrorEnabled();
|
||||
}
|
||||
|
|
|
@ -183,4 +183,29 @@ public class StandardLogRepository implements LogRepository {
|
|||
public ComponentLog getLogger() {
|
||||
return componentLogger;
|
||||
}
|
||||
|
||||
private boolean hasObserver(final LogLevel logLevel) {
|
||||
final Collection<LogObserver> logLevelObservers = observers.get(logLevel);
|
||||
return (logLevelObservers != null && !logLevelObservers.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return hasObserver(LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled() {
|
||||
return hasObserver(LogLevel.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled() {
|
||||
return hasObserver(LogLevel.WARN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled() {
|
||||
return hasObserver(LogLevel.ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,29 +167,29 @@ public class SimpleProcessLogger implements ComponentLog {
|
|||
logRepository.addLogMessage(LogLevel.TRACE, msg, os, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled() {
|
||||
return logger.isWarnEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled() {
|
||||
return logger.isTraceEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return logger.isDebugEnabled() || logRepository.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled() {
|
||||
return logger.isInfoEnabled();
|
||||
return logger.isInfoEnabled() || logRepository.isInfoEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled() {
|
||||
return logger.isWarnEnabled() || logRepository.isWarnEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return logger.isDebugEnabled();
|
||||
return logger.isErrorEnabled() || logRepository.isErrorEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue