Skip to content

🔊 add logs for kakao#54

Merged
bess-cater merged 1 commit intodevfrom
feat/logs
Sep 18, 2025
Merged

🔊 add logs for kakao#54
bess-cater merged 1 commit intodevfrom
feat/logs

Conversation

@bess-cater
Copy link
Copy Markdown
Contributor

어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

세부 내용 - 왜 해당 PR이 필요한지 자세하게 설명해주세요

  • 카카오 로그인 오류 파악 위해 로그 추가

PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @bess-cater, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 카카오 로그인 과정에서 발생할 수 있는 문제를 진단하고 이해하는 데 도움이 되도록 포괄적인 로깅 기능을 도입합니다. 전역 로깅 설정을 구축하고, 특히 KakaoClient 내에서 토큰 요청의 성공, 실패 및 다양한 예외 상황에 대한 세부 정보를 기록하도록 기능을 확장했습니다.

Highlights

  • 로깅 설정 추가: 애플리케이션 전반에 걸쳐 로깅을 활성화하기 위해 src/main.py 파일에 기본 로깅 설정을 추가했습니다.
  • 카카오 클라이언트 로깅 통합: src/utils/kakao_client.py 파일에 로깅 기능을 통합하여 카카오 API 요청 및 응답에 대한 상세 정보를 기록합니다.
  • 카카오 토큰 요청 오류 처리 개선: 카카오 토큰 요청 시 발생할 수 있는 다양한 오류(HTTP 상태 코드 불일치, 타임아웃, 일반 요청 예외)에 대한 처리 로직을 강화하고, 관련 오류 메시지를 로깅하도록 했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 PR은 카카오 로그인 흐름을 더 잘 추적하기 위해 로깅을 추가하는 내용으로, 디버깅에 큰 도움이 될 것입니다. 몇 가지 개선할 점을 발견했습니다. main.py 파일에 중복된 import 구문이 있고, 다른 모듈에 있는 로깅 설정 때문에 새로 추가된 로깅 설정이 의도대로 동작하지 않을 가능성이 있습니다. 또한 kakao_client.py에서는 인증 코드의 일부를 로깅하는 부분에서 사소한 보안 위험이 있으며, import 순서도 개선이 필요해 보입니다. 이 점들을 수정하면 코드가 더 깔끔해지고 로깅이 더 안정적이고 안전해질 것입니다.

Comment thread src/main.py
Comment on lines +16 to +19
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

logging.basicConfig() 호출은 효과가 없을 가능성이 높습니다. 7행에서 import하는 api.user 모듈에서도 logging.basicConfig()를 호출하고 있기 때문입니다. basicConfig()는 처음 호출될 때만 동작하므로, api.user의 설정이 우선 적용되고 포맷 문자열이 포함된 이 상세 설정은 무시될 것입니다. 이 문제를 해결하려면 로깅 설정을 한 곳에서 중앙 집중식으로 관리해야 합니다. api.user 및 다른 모듈에서 basicConfig 호출을 제거하고, 애플리케이션 전체에서 일관된 로깅을 보장하기 위해 main.py의 이 설정만 유지하는 것을 권장합니다.

Comment thread src/main.py
from database.connection import get_db

import logging
from fastapi import FastAPI
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

FastAPI는 1행에서 이미 import 되었습니다. 이 import 구문은 중복되므로 코드를 깔끔하게 유지하기 위해 제거하는 것이 좋습니다.

Comment thread src/utils/kakao_client.py
from typing import Dict, Optional
import os

import logging
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

PEP 8에 따르면 import는 표준 라이브러리, 서드파티, 로컬 애플리케이션 순으로 그룹화하고 각 그룹 내에서 알파벳순으로 정렬해야 합니다. logging은 표준 라이브러리 import이므로 os, typing과 같은 다른 표준 라이브러리 import와 함께, requests와 같은 서드파티 import보다 앞에 위치해야 합니다.

Comment thread src/utils/kakao_client.py
response.raise_for_status()

token_data = response.json()
logger.info(f"Kakao token received successfully for code ending with {authorization_code[-4:]}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

authorization_code와 같은 민감한 정보를 로깅하는 것은 일부만 로깅하더라도 보안 위험이 될 수 있습니다. 이 로그가 수집되어 외부에 노출될 가능성이 있습니다. 민감한 토큰이나 코드의 어떤 부분도 로깅하지 않는 것이 가장 좋습니다.

Suggested change
logger.info(f"Kakao token received successfully for code ending with {authorization_code[-4:]}")
logger.info("Kakao token received successfully")

@bess-cater bess-cater merged commit 0fb5211 into dev Sep 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant