BJ-917: Provide logs

This commit is contained in:
a.romanov 2020-05-27 15:34:15 +03:00 committed by a.romanov
parent 468984cfe4
commit 3df63949b5
6 changed files with 31 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package com.rbkmoney.threeds.server.storage.client;
import com.rbkmoney.threeds.server.domain.root.rbkmoney.RBKMoneyPreparationRequest;
import com.rbkmoney.threeds.server.domain.root.rbkmoney.RBKMoneyPreparationResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.EnableRetry;
@ -11,6 +12,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientResponseException;
import org.springframework.web.client.RestTemplate;
@Slf4j
@Service
@EnableRetry
@RequiredArgsConstructor
@ -26,10 +28,15 @@ public class ThreeDsServerClient {
backoff = @Backoff(delay = 60_000L),
maxAttempts = Integer.MAX_VALUE)
public RBKMoneyPreparationResponse preparationFlow(RBKMoneyPreparationRequest request) {
return restTemplate.postForEntity(
log.info("Request: {}", request);
RBKMoneyPreparationResponse response = restTemplate.postForEntity(
url,
request,
RBKMoneyPreparationResponse.class)
.getBody();
log.info("Response: {}", response);
return response;
}
}

View File

@ -21,10 +21,10 @@ public class RetryListenerConfig {
public <T, E extends Throwable> void onError(
RetryContext context, RetryCallback<T, E> callback,
Throwable throwable) {
log.warn("Retrying method={}, count={} because of the exception={}",
log.warn("Retrying method={}, count={} because of the exception",
context.getAttribute("context.name"),
context.getRetryCount(),
throwable.toString());
throwable);
}
});
}

View File

@ -6,12 +6,14 @@ import com.rbkmoney.threeds.server.storage.mapper.CardRangeMapper;
import com.rbkmoney.threeds.server.storage.repository.CardRangeRepository;
import com.rbkmoney.threeds.server.storage.service.PreparationFlowService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import static java.util.stream.Collectors.toList;
@Slf4j
@Service
@RequiredArgsConstructor
public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
@ -22,6 +24,7 @@ public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
@Override
public void initRBKMoneyPreparationFlow(InitRBKMoneyPreparationFlowRequest request) {
log.info("Init RBK.money preparation flow for providerId={}", request.getProviderId());
preparationFlowService.init(request.getProviderId());
}
@ -34,6 +37,7 @@ public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
.map(mapper::toDomain)
.collect(toList());
log.info("Return {} cardRanges for providerId={}", cardRanges.size(), providerId);
return new GetCardRangesResponse()
.setProviderId(providerId)
.setCardRanges(cardRanges);

View File

@ -7,8 +7,10 @@ import com.rbkmoney.threeds.server.storage.exception.ChallengeFlowTransactionInf
import com.rbkmoney.threeds.server.storage.mapper.ChallengeFlowTransactionInfoMapper;
import com.rbkmoney.threeds.server.storage.repository.ChallengeFlowTransactionInfoRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@RequiredArgsConstructor
public class ChallengeFlowTransactionInfoStorageHandler implements ChallengeFlowTransactionInfoStorageSrv.Iface {
@ -19,11 +21,14 @@ public class ChallengeFlowTransactionInfoStorageHandler implements ChallengeFlow
@Override
public void saveChallengeFlowTransactionInfo(ChallengeFlowTransactionInfo transactionInfo) {
ChallengeFlowTransactionInfoEntity entity = mapper.toEntity(transactionInfo);
log.debug("Save challengeFlowTransactionInfo with transactionId={}", transactionInfo.getTransactionId());
repository.save(entity);
}
@Override
public ChallengeFlowTransactionInfo getChallengeFlowTransactionInfo(String transactionId) {
log.debug("Return challengeFlowTransactionInfo with transactionId={}", transactionId);
return repository.findByTransactionId(transactionId)
.map(mapper::toDomain)
.orElseThrow(() -> new ChallengeFlowTransactionInfoNotFoundException("transactionId=" + transactionId));

View File

@ -7,10 +7,12 @@ import com.rbkmoney.threeds.server.storage.mapper.SerialNumMapper;
import com.rbkmoney.threeds.server.storage.repository.CardRangeRepository;
import com.rbkmoney.threeds.server.storage.repository.SerialNumRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
@Slf4j
@Service
@RequiredArgsConstructor
public class PreparationFlowDataUpdater {
@ -32,6 +34,14 @@ public class PreparationFlowDataUpdater {
String providerId = response.getProviderId();
String serialNum = response.getSerialNum();
log.info("Update preparation flow data for providerId={}: " +
"serialNum={}, cardRanges=[added={}, modified={}, deleted={}]",
providerId,
serialNum,
response.getAddedCardRanges().size(),
response.getModifiedCardRanges().size(),
response.getDeletedCardRanges().size());
cardRangeRepository.saveAll(cardRangeMapper.toEntities(response.getAddedCardRanges(), providerId));
cardRangeRepository.saveAll(cardRangeMapper.toEntities(response.getModifiedCardRanges(), providerId));
cardRangeRepository.deleteAll(cardRangeMapper.toEntities(response.getDeletedCardRanges(), providerId));

View File

@ -3,8 +3,9 @@
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<root level="warn">
<root level="WARN">
<appender-ref ref="CONSOLE"/>
</root>
<logger name="com.rbkmoney.woody" level="ALL"/>
<logger name="com.rbkmoney.threeds.server.storage" level="DEBUG"/>
</configuration>