|
|
|
|
@ -73,6 +73,18 @@ class ConditionEvaluationReportLoggingListenerTests {
@@ -73,6 +73,18 @@ class ConditionEvaluationReportLoggingListenerTests {
|
|
|
|
|
assertThat(output).contains("CONDITIONS EVALUATION REPORT"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void logsInfoGuidanceToEnableDebugLoggingOnApplicationFailedEvent(CapturedOutput output) { |
|
|
|
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); |
|
|
|
|
this.initializer.initialize(context); |
|
|
|
|
context.register(ErrorConfig.class); |
|
|
|
|
assertThatExceptionOfType(Exception.class).isThrownBy(context::refresh) |
|
|
|
|
.satisfies((ex) -> withInfoLogging(() -> context.publishEvent( |
|
|
|
|
new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex)))); |
|
|
|
|
assertThat(output).doesNotContain("CONDITONS EVALUATION REPORT") |
|
|
|
|
.contains("re-run your application with 'debug' enabled"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void canBeUsedInApplicationContext() { |
|
|
|
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); |
|
|
|
|
@ -93,10 +105,18 @@ class ConditionEvaluationReportLoggingListenerTests {
@@ -93,10 +105,18 @@ class ConditionEvaluationReportLoggingListenerTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void withDebugLogging(Runnable runnable) { |
|
|
|
|
withLoggingLevel(Level.DEBUG, runnable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void withInfoLogging(Runnable runnable) { |
|
|
|
|
withLoggingLevel(Level.INFO, runnable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void withLoggingLevel(Level logLevel, Runnable runnable) { |
|
|
|
|
Logger logger = ((LoggerContext) LoggerFactory.getILoggerFactory()) |
|
|
|
|
.getLogger(ConditionEvaluationReportLogger.class); |
|
|
|
|
Level currentLevel = logger.getLevel(); |
|
|
|
|
logger.setLevel(Level.DEBUG); |
|
|
|
|
logger.setLevel(logLevel); |
|
|
|
|
try { |
|
|
|
|
runnable.run(); |
|
|
|
|
} |
|
|
|
|
|