Skip to content

Commit

Permalink
Merge pull request #182 from Make-A-Wish-Sopt/feature/jiyoung_#181-de…
Browse files Browse the repository at this point in the history
…velop

[ADD] 로그 추가
  • Loading branch information
wlwpfh authored Sep 4, 2024
2 parents 845130c + b1eceb7 commit 135ce50
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import java.time.LocalDateTime;
import java.util.Objects;

import static com.sopterm.makeawish.common.message.ErrorMessage.*;
import static com.sopterm.makeawish.common.message.ErrorMessage.FAILED_VALIDATE_KAKAO_LOGIN;
import static com.sopterm.makeawish.common.message.ErrorMessage.INVALID_CODE;

@Slf4j
@Service
Expand Down Expand Up @@ -58,7 +59,10 @@ public String getAccessTokenByCode(String code, String redirectUri) throws JsonP
);
// HTTP 응답 (JSON) -> 액세스 토큰 파싱
String responseBody = response.getBody();
if(Objects.isNull(responseBody)) throw new IllegalArgumentException(INVALID_CODE.getMessage());
if (Objects.isNull(responseBody)) {
log.error("KakaoTokenManager.getAccessTokenByCode, 응답값이 없습니다. code = {}", code);
throw new IllegalArgumentException(INVALID_CODE.getMessage());
}
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(responseBody);
return jsonNode.get("access_token").asText();
Expand All @@ -80,6 +84,7 @@ public StringBuilder getKakaoInfo(String socialToken) {
br.close();
return result;
} catch (IOException e) {
log.error("KakaoTokenManager.getKakaoInfo, e = {}, socialToken = {}", e.getMessage());
throw new IllegalArgumentException(FAILED_VALIDATE_KAKAO_LOGIN.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public AuthSignInResponseDTO socialLogin(String code, String redirectUri) {
String kakaoAccessToken = null;
try {
kakaoAccessToken = kakaoTokenManager.getAccessTokenByCode(code, redirectUri);
} catch (JsonProcessingException j) {
} catch (JsonProcessingException e) {
log.error("KakaoLoginService.socialLogin, code = {}, redirectUri = {}, e = {}", code, redirectUri, e.getMessage());
throw new IllegalArgumentException(CODE_PARSE_ERROR.getMessage());
}
val kakaoInfo = kakaoTokenManager.getKakaoInfo(kakaoAccessToken);
Expand Down
42 changes: 42 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>

<property name="CONSOLE_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %magenta([%thread]) %highlight([%-3level]) %logger{5} - %msg %n" />

<!-- Console appender 설정 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>${CONSOLE_PATTERN}</Pattern>
</encoder>
</appender>


<logger name="jdbc" level="OFF" additive="false">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="jdbc.sqlonly" level="DEBUG" additive="false" >
<appender-ref ref="STDOUT"/>
</logger>
<logger name="jdbc.sqltiming" level="OFF" additive="false" >
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.hibernate.SQL" level="DEBUG" additive="false">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.sopterm.makeawish.common" level="DEBUG" additive="false" >
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.sopterm.makeawish.config" level="DEBUG" additive="false" >
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.sopterm.makeawish.service" level="DEBUG" additive="false" >
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.sopterm.makeawish.domain" level="DEBUG" additive="false" >
<appender-ref ref="STDOUT"/>
</logger>

<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

0 comments on commit 135ce50

Please sign in to comment.