From 8c16d37460926370c44e6330ab93616c074e4a5c Mon Sep 17 00:00:00 2001 From: Fabien Cerf Date: Tue, 23 Jun 2020 15:55:22 +0200 Subject: [PATCH] New Debug Log Information --- .../service/AuthCodeGenerationService.java | 5 ++++- .../service/AuthCodeVerificationService.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeGenerationService.java b/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeGenerationService.java index 22c7a13..f854ae5 100644 --- a/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeGenerationService.java +++ b/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeGenerationService.java @@ -15,6 +15,9 @@ import java.security.SecureRandom; import java.time.LocalDate; import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import static net.logstash.logback.argument.StructuredArguments.kv; @Service @Transactional(readOnly = true) @@ -45,7 +48,7 @@ public AuthorizationCodeResponseDto create(AuthorizationCodeCreateDto createDto) AuthorizationCode authorizationCode = new AuthorizationCode(authCode, createDto.getOnsetDate(), createDto.getOnsetDate().minusDays(onsetSubtractionDays), ZonedDateTime.now().plusMinutes(codeExpirationDelay)); authorizationCodeRepository.saveAndFlush(authorizationCode); log.info("New authorizationCode saved with id '{}'.", authorizationCode.getId()); - log.debug("New authorizationCode saved with id '{}' and code '{}' and onset '{}'.", authorizationCode.getId(), authorizationCode.getCode(), authorizationCode.getOnsetDate()); + log.debug("New authorizationCode saved: {}, {}, {}.", kv("id", authorizationCode.getId()), kv("creationDateTime", authorizationCode.getCreationDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)), kv("onsetDate",authorizationCode.getOnsetDate())); return new AuthorizationCodeResponseDto(authorizationCode.getCode()); } diff --git a/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeVerificationService.java b/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeVerificationService.java index 0f181d0..92c3e9f 100644 --- a/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeVerificationService.java +++ b/src/main/java/ch/admin/bag/covidcode/authcodegeneration/service/AuthCodeVerificationService.java @@ -12,6 +12,8 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import static net.logstash.logback.argument.StructuredArguments.kv; + @Service @Transactional(readOnly = true) @Slf4j @@ -48,6 +50,7 @@ public AuthorizationCodeVerifyResponseDto verify(String code, String fake) { } existingCode.incrementCallCount(); + log.debug("AuthorizationCode verified: '{}', '{}'", kv("id", existingCode.getId()), kv("callCount", existingCode.getCallCount())); return new AuthorizationCodeVerifyResponseDto(tokenProvider.createToken(existingCode.getOnsetDate().format(DATE_FORMATTER), fake)); }