Procházet zdrojové kódy

SONAR-21352 Change log level to Warning (#10622)

tags/10.5.0.89998
OrlovAlexander před 3 měsíci
rodič
revize
e0a657e489

+ 6
- 3
server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java Zobrazit soubor

import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.slf4j.event.Level.DEBUG; import static org.slf4j.event.Level.DEBUG;
import static org.slf4j.event.Level.WARN;
import static org.sonar.db.DbTester.create; import static org.sonar.db.DbTester.create;
import static org.sonar.db.webhook.WebhookTesting.newGlobalWebhook; import static org.sonar.db.webhook.WebhookTesting.newGlobalWebhook;
import static org.sonar.db.webhook.WebhookTesting.newWebhook; import static org.sonar.db.webhook.WebhookTesting.newWebhook;


assertThat(caller.countSent()).isEqualTo(2); assertThat(caller.countSent()).isEqualTo(2);
assertThat(logTester.logs(DEBUG)).contains("Sent webhook 'First' | url=http://url1 | time=1234ms | status=200"); assertThat(logTester.logs(DEBUG)).contains("Sent webhook 'First' | url=http://url1 | time=1234ms | status=200");
assertThat(logTester.logs(DEBUG)).contains("Failed to send webhook 'Second' | url=http://url2 | message=Fail to connect");
assertThat(logTester.logs(WARN)).contains("Failed to send webhook 'Second' | url=http://url2 | message=Fail to connect");
verify(deliveryStorage, times(2)).persist(any(WebhookDelivery.class)); verify(deliveryStorage, times(2)).persist(any(WebhookDelivery.class));
verify(deliveryStorage).purge(); verify(deliveryStorage).purge();
verifyLogStatistics(2, 0); verifyLogStatistics(2, 0);


assertThat(caller.countSent()).isEqualTo(5); assertThat(caller.countSent()).isEqualTo(5);
List<String> debugLogs = logTester.logs(DEBUG); List<String> debugLogs = logTester.logs(DEBUG);
List<String> warnLogs = logTester.logs(WARN);
assertThat(debugLogs) assertThat(debugLogs)
.contains("Sent webhook '1First' | url=http://url1 | time=1234ms | status=200") .contains("Sent webhook '1First' | url=http://url1 | time=1234ms | status=200")
.contains("Failed to send webhook '2Second' | url=http://url2 | message=Fail to connect 1")
.contains("Failed to send webhook '3Third' | url=http://url3 | message=Fail to connect 2")
.contains("Sent webhook '4Fourth' | url=http://url4 | time=5678ms | status=200") .contains("Sent webhook '4Fourth' | url=http://url4 | time=5678ms | status=200")
.contains("Sent webhook '5Fifth' | url=http://url5 | time=9256ms | status=200"); .contains("Sent webhook '5Fifth' | url=http://url5 | time=9256ms | status=200");
assertThat(warnLogs)
.contains("Failed to send webhook '2Second' | url=http://url2 | message=Fail to connect 1")
.contains("Failed to send webhook '3Third' | url=http://url3 | message=Fail to connect 2");
verify(deliveryStorage, times(5)).persist(any(WebhookDelivery.class)); verify(deliveryStorage, times(5)).persist(any(WebhookDelivery.class));
verify(deliveryStorage).purge(); verify(deliveryStorage).purge();
verifyLogStatistics(3, 2); verifyLogStatistics(3, 2);

+ 1
- 1
server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebHooksImpl.java Zobrazit soubor

private static void log(WebhookDelivery delivery) { private static void log(WebhookDelivery delivery) {
Optional<String> error = delivery.getErrorMessage(); Optional<String> error = delivery.getErrorMessage();
if (error.isPresent()) { if (error.isPresent()) {
LOGGER.debug("Failed to send webhook '{}' | url={} | message={}",
LOGGER.warn("Failed to send webhook '{}' | url={} | message={}",
delivery.getWebhook().getName(), delivery.getWebhook().getUrl(), error.get()); delivery.getWebhook().getName(), delivery.getWebhook().getUrl(), error.get());
} else { } else {
LOGGER.debug("Sent webhook '{}' | url={} | time={}ms | status={}", LOGGER.debug("Sent webhook '{}' | url={} | time={}ms | status={}",

Načítá se…
Zrušit
Uložit