Skip to content

Commit

Permalink
Merge pull request #441 from woowacourse-teams/refactor/#432
Browse files Browse the repository at this point in the history
폴링 방식으로 보낸 채팅 요청이 모두 로그에 찍히는 현상 해결
  • Loading branch information
Mingyum-Kim authored Aug 22, 2024
2 parents 33f8bd9 + 7983c93 commit 2ddd688
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package mouda.backend.aop.logging;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExceptRequestLogging {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.stream.Collectors.*;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

import org.aspectj.lang.JoinPoint;
Expand Down Expand Up @@ -31,6 +32,13 @@ public void allController() {
@Before("allController()")
public void logController(JoinPoint joinPoint) {
HttpServletRequest request = getHttpServletRequest();

MethodSignature signature = (MethodSignature)joinPoint.getSignature();
Method method = signature.getMethod();
if (method.isAnnotationPresent(ExceptRequestLogging.class)) {
return;
}

String uri = request.getRequestURI();
String httpMethod = request.getMethod();
String queryParameters = getQueryParameters(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import mouda.backend.aop.logging.ExceptRequestLogging;
import mouda.backend.chat.dto.request.ChatCreateRequest;
import mouda.backend.chat.dto.request.DateTimeConfirmRequest;
import mouda.backend.chat.dto.request.LastReadChatRequest;
Expand Down Expand Up @@ -43,6 +44,7 @@ public ResponseEntity<Void> createChat(
}

@Override
@ExceptRequestLogging
@GetMapping
public ResponseEntity<RestResponse<ChatFindUnloadedResponse>> findUnloadedChats(
@PathVariable Long darakbangId,
Expand All @@ -57,6 +59,7 @@ public ResponseEntity<RestResponse<ChatFindUnloadedResponse>> findUnloadedChats(
}

@Override
@ExceptRequestLogging
@GetMapping("/preview")
public ResponseEntity<RestResponse<ChatPreviewResponses>> findChatPreviews(
@PathVariable Long darakbangId,
Expand Down

0 comments on commit 2ddd688

Please sign in to comment.