Skip to content

Commit

Permalink
chore(server): cleanup log (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
junglesub authored Nov 5, 2024
1 parent a15a677 commit 937fe58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/main/java/app/handong/feed/interceptor/DefaultInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ public class DefaultInterceptor implements HandlerInterceptor {
//컨트롤러 진입 전에 호출되는 메서드
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
logger.info("preHandle / request [{}]", request);
/*request.setAttribute("reqTest", "done");
response.setHeader("resTest", "done1");
logger.info("preHandle / reqTest [{}]", request.getAttribute("reqTest"));
logger.info("preHandle / resTest [{}]", response.getHeader("resTest"));
*/
//logger.info("preHandle / refreshToken [{}]", request.getHeader("refreshToken"));
logger.info("preHandle / accessToken [{}]", request.getHeader("Authorization"));
if (request.getHeader("Authorization") != null) {
TokenFactory tokenFactory = new TokenFactory();
String reqUserId = tokenFactory.verifyToken(request.getHeader("Authorization").replaceAll("Bearer ", ""));
Expand All @@ -36,18 +28,22 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons

String requestURI = request.getRequestURI();
String requestMethod = request.getMethod();
String ipAddr = request.getHeader("X-Forwarded-For");
if (ipAddr == null || ipAddr.isEmpty()) {
ipAddr = request.getRemoteAddr();
}
logger.info("preHandle [{} {}] : {} / {}", requestMethod, requestURI, ipAddr, request.getAttribute("reqUserId"));
return true;
}

//컨트롤러 실행 후에 호출되는 메서드
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
logger.info("postHandle / request [{}]", request);
// logger.info("postHandle / request [{}]", request);
}

//모든것을 마친 후 실행되는 메서드
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
logger.info("afterCompletion / request [{}]", request);
}
}
4 changes: 2 additions & 2 deletions src/main/java/app/handong/feed/util/TokenFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public String verifyToken(String token) throws Exception {
String due = arrayVal[1];
NowDate nowDate = new NowDate();
String now = nowDate.getNow();
System.out.println("due : " + due);
System.out.println("now : " + now);
// System.out.println("due : " + due);
// System.out.println("now : " + now);

String[] arrayNow = {due, now};
Arrays.sort(arrayNow);
Expand Down

0 comments on commit 937fe58

Please sign in to comment.