Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] 로그 추가 #182

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading