From 1100bada22cd83ec2ab0336bb2c5ed555f218771 Mon Sep 17 00:00:00 2001 From: Jaehyeon Date: Thu, 28 Mar 2024 23:30:58 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?logging=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/AdminController.java | 13 +---- .../service/DisasterEventHandler.java | 15 ------ .../disaster/service/DisasterService.java | 1 - .../domain/member/service/MemberService.java | 2 - .../backend/support/logging/LogAspect.java | 48 ------------------- .../fcm/service/FcmMessageProvider.java | 4 -- .../service/DisasterDataCollector.java | 3 -- 7 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 daepiro-api/src/main/java/com/numberone/backend/support/logging/LogAspect.java diff --git a/daepiro-api/src/main/java/com/numberone/backend/domain/admin/controller/AdminController.java b/daepiro-api/src/main/java/com/numberone/backend/domain/admin/controller/AdminController.java index 70daf5c5..0a41660a 100644 --- a/daepiro-api/src/main/java/com/numberone/backend/domain/admin/controller/AdminController.java +++ b/daepiro-api/src/main/java/com/numberone/backend/domain/admin/controller/AdminController.java @@ -20,18 +20,7 @@ public class AdminController { private final AdminService adminService; private final DisasterService disasterService; - @Operation(summary = "서버에 지역별 대피소 정보 Json 파일로 업로드하기", description = - """ - - 🔥 (주의) Shelter Database 정보를 json 형태로 서버 스토리지에 저장하는 기능으로, 10 분 이상 소요됩니다. - - 요청 시, 현재 저장된 대피소 db 를 기반으로 - - 지역 별 대피소 정보를 Json 형태로 정리하여 서버 스토리지에 저장합니다. - - 대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다. - - """) + @Operation(summary = "서버에 지역별 대피소 정보 Json 파일로 업로드하기") // todo: s3 에서 이미 만들어진 파일을 내려주도록 하자. @PostMapping("/shelter-init") public ResponseEntity uploadAllShelterInfo() { return ResponseEntity.created(URI.create("/api/admin/shelter-init")) diff --git a/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterEventHandler.java b/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterEventHandler.java index 230aa21e..ff3713a9 100644 --- a/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterEventHandler.java +++ b/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterEventHandler.java @@ -36,12 +36,6 @@ public class DisasterEventHandler { @Transactional(jakarta.transaction.Transactional.TxType.REQUIRES_NEW) @TransactionalEventListener public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disasterEvent) { - log.info(""" - [신규 재난 발생 이벤트 감지!] - 현재 재난 위치에 존재하면서, 발생한 재난 유형이 온보딩 때 선택한 재난 유형인 회원들에게 알림을 보냅니다. - 또한, 현재 재난위치에 존재하지는 않지만 온보딩을 통해 알림을 받고자 하는 지역 + 재난 유형이 발생한 경우에 대해서도 알림을 보냅니다. - 알람은 중복을 제거하여 발송됩니다. - """); String type = disasterEvent.getType().code2kor(); String disasterLocation = disasterEvent.getLocation(); String title = String.format("[긴급] %s %s 발생", disasterLocation, type); @@ -65,8 +59,6 @@ public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disas ); member.updateSafety(false); log.info("received member id: {} Notification id: {} ", member.getId(), savedNotificationEntity.getId()); - log.info(title); - log.info(message); return member.getId(); }).filter(Objects::nonNull).toList(); @@ -77,7 +69,6 @@ public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disas }).filter(Objects::nonNull).toList(); // fcm 메세지 일괄 전송 - log.info("현재 재난 위치에 있는, {} 재난 유형을 허용한 회원들에게 알림을 전송합니다.", type); fcmMessageProvider.sendFcmToMembers(fcmTokensByPresentLocationAndOnboardingDisasterType, title, message); // 온보딩때 선택한 지역에 대한 알림을 받고자 하는 회원 리스트를 필터링합니다. @@ -88,7 +79,6 @@ public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disas .toList(); - log.info("회원이 재난문자 알림을 받고자 하는 지역에 대한 푸시알람을 중복을 제거하여 보냅니다. 이때 재난 유형도 필터링합니다."); // 해당 회원의 온보딩 리스트 및 알림을 허용하는 재난 유형을 기준으로 알림을 보낸다. List targetFcmsByOnboardingRegionsAndDisasterTypes = distinctMemberIdListByOnboardingRegions.stream() .flatMap(memberId -> { @@ -116,15 +106,10 @@ public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disas @Transactional(jakarta.transaction.Transactional.TxType.REQUIRES_NEW) @TransactionalEventListener public void sendFcmToFriends(DisasterEvent disasterEvent) { - log.info(""" - [신규 재난 발생 이벤트 감지!] - 재난 지역에 위치하는 회원의 가족들에게 알림을 보냅니다! - """); String disasterLocation = disasterEvent.getLocation(); // 현재 재난 위치에 있는 회원 아이디 리스트 List memberIdListByOnlyPresentLocation = memberRepository.findAllByLocation(disasterLocation); - log.info("위험 지역에 위치한 회원의 가족에게 알림을 보냅니다."); // 해당 회원의 가족에게 알림을 보낸다. memberIdListByOnlyPresentLocation.forEach(memberId -> { Member member = memberRepository.findById(memberId) diff --git a/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterService.java b/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterService.java index ba61e8de..ceaee675 100644 --- a/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterService.java +++ b/daepiro-api/src/main/java/com/numberone/backend/domain/disaster/service/DisasterService.java @@ -101,7 +101,6 @@ public void save(SaveAdminDisasterRequest saveDisasterRequest) { dateTime ) ); - log.info("재난 발생 이벤트 발행"); eventPublisher.publishEvent(DisasterEvent.of(savedDisaster)); // 신규 재난 발생 이벤트 } diff --git a/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java b/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java index 61315de5..ba7eb49b 100644 --- a/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java +++ b/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java @@ -80,8 +80,6 @@ public UploadProfileImageResponse uploadProfileImage(MultipartFile image) { .orElseThrow(NotFoundMemberException::new); String imageUrl = s3Provider.uploadImage(image); - log.info("[회원의 프로필 이미지를 업로드하였습니다.] id:{} url:{}", member.getId(), imageUrl); - member.updateProfileImageUrl(imageUrl); return UploadProfileImageResponse.of(imageUrl); diff --git a/daepiro-api/src/main/java/com/numberone/backend/support/logging/LogAspect.java b/daepiro-api/src/main/java/com/numberone/backend/support/logging/LogAspect.java deleted file mode 100644 index 5996c3a5..00000000 --- a/daepiro-api/src/main/java/com/numberone/backend/support/logging/LogAspect.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.numberone.backend.support.logging; - -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.*; -import org.springframework.stereotype.Component; - -import java.util.Arrays; -import java.util.Objects; - -@Component -@Aspect -@Slf4j -public class LogAspect { - - @Pointcut("execution(* com.numberone.backend.domain..*Controller.*(..))") - public void controller() { - } - - @Pointcut("execution(* com.numberone.backend.domain..*Service.*(..))") - public void service() { - } - - @Before("controller()") - public void beforeRequest(JoinPoint joinPoint) { - log.info(" Start request ---> {} ", joinPoint.getSignature().toShortString()); - Arrays.stream(joinPoint.getArgs()) - .map(Object::toString) - .map(str -> "\t" + str) - .forEach(log::info); - } - - @AfterReturning(pointcut = "controller()", returning = "returnValue") - public void afterReturningLogging(JoinPoint joinPoint, Object returnValue) { - log.info(" End request ---> {} ", joinPoint.getSignature().toShortString()); - - if (Objects.isNull(returnValue)) return; - - log.info("\t response info: {}", returnValue.toString()); - } - - @AfterThrowing(pointcut = "controller()", throwing = "e") - public void afterThrowingLogging(JoinPoint joinPoint, Exception e) { - log.error("###Occured error in request {}", joinPoint.getSignature().toShortString()); - log.error("\t{}", e.getMessage()); - } - -} diff --git a/daepiro-common/src/main/java/com/numberone/backend/provider/fcm/service/FcmMessageProvider.java b/daepiro-common/src/main/java/com/numberone/backend/provider/fcm/service/FcmMessageProvider.java index 263bc175..91d1e525 100644 --- a/daepiro-common/src/main/java/com/numberone/backend/provider/fcm/service/FcmMessageProvider.java +++ b/daepiro-common/src/main/java/com/numberone/backend/provider/fcm/service/FcmMessageProvider.java @@ -30,15 +30,12 @@ public void sendFcm(String token, String title, String body) { try { //String response = FirebaseMessaging.getInstance().send(message); FirebaseMessaging.getInstance().send(message); - log.info("Fcm 푸시 알람을 성공적으로 전송하였습니다."); - log.info("[FCM Message] {} : {}", title, body); } catch (Exception e) { log.error("Fcm 푸시 알람을 전송하는 도중에 에러가 발생했습니다. {}", e.getMessage()); } } public void sendFcmToMembers(List tokens, String title, String body) { - log.info("{} 건의 푸시알람을 전송합니다.", tokens.size()); if (tokens.isEmpty()) return; List messages = tokens.stream().map( token -> Message.builder() @@ -65,7 +62,6 @@ public void sendFcmToMembers(List tokens, String title, String body) { ); log.error("FCM 메세징 실패 토큰 목록 출력: {}", failedTokens); } - log.info("Fcm 푸시 알람을 전송하였습니다."); } catch (Exception e) { log.error("Fcm 푸시 알람을 전송하는 도중에 에러가 발생했습니다. {}", e.getMessage()); } diff --git a/daepiro-crawler/src/main/java/com/numberone/backend/domain/disaster/service/DisasterDataCollector.java b/daepiro-crawler/src/main/java/com/numberone/backend/domain/disaster/service/DisasterDataCollector.java index 1caa84a5..c15c782e 100644 --- a/daepiro-crawler/src/main/java/com/numberone/backend/domain/disaster/service/DisasterDataCollector.java +++ b/daepiro-crawler/src/main/java/com/numberone/backend/domain/disaster/service/DisasterDataCollector.java @@ -47,7 +47,6 @@ public class DisasterDataCollector { @Scheduled(fixedDelay = 60 * 1000) public void collectData() { - log.info("[ Disaster data Collector is running! ] "); URI uri = UriComponentsBuilder .fromUriString(disasterProperties.getApiUrl()) .queryParam("ServiceKey", disasterProperties.getSecretKey()) @@ -67,7 +66,6 @@ public void collectData() { List disasters = disasterDataResponse.getDisasterMsg().get(1).getRowItems(); Long topDisasterNum = Long.parseLong(disasters.get(0).getMsgId()); if (topDisasterNum > latestDisasterNum) { - log.info("new disaster"); crawlingDisasterTypeV2(); if (disasterTypeMap.size() != disasters.size()) throw new NotFoundCrawlingException(); @@ -108,7 +106,6 @@ private void convertAndSave(SaveDisasterRequest saveDisasterRequest) { dateTime ) ); - log.info("재난 발생 이벤트 발행"); eventPublisher.publishEvent(DisasterEvent.of(savedDisaster)); // 신규 재난 발생 이벤트 }