Skip to content

[FEAT] JSON 로깅 설정 추가#172

Merged
wlswnsdn merged 3 commits into
developfrom
feat/#169-json-logging
Jan 26, 2026
Merged

[FEAT] JSON 로깅 설정 추가#172
wlswnsdn merged 3 commits into
developfrom
feat/#169-json-logging

Conversation

@wlswnsdn

Copy link
Copy Markdown
Contributor

PR 제목

[FEAT] JSON 로깅 설정 추가

✨ 변경 유형 (하나 이상 선택)

  • Feat: 새로운 기능 추가
  • Fix: 버그 수정
  • Refactor: 코드 리팩토링 (기능 변경 없음)
  • Docs: 문서 업데이트 (주석, README 등)
  • Chore: 기타 변경 (빌드 설정, 라이브러리 업데이트 등)
  • Test: 테스트 코드 추가/수정

📚 변경 내용

JSON 포맷 로깅을 위한 설정 추가.
프로덕션 환경에서는 JSON 포맷으로, 그 외 환경에서는 색상 포맷으로 로깅되도록 설정.
기존의 logging.basicConfig 대신 setup_logging 함수를 사용하여 로깅 설정을 적용.

⚙️ 주요 작업 (선택 사항)

  • 새로운 API 추가 (API 명세서 링크 또는 간단한 정보)
  • 데이터베이스 스키마 변경 (변경 내용 명시)
  • 외부 라이브러리 추가/제거 (라이브러리 명시)

✅ 체크리스트

  • 코드 컨벤션을 준수했습니다.
  • 변경 사항에 대한 문서 업데이트가 필요한 경우 반영했습니다.

🔗 관련 이슈 (선택 사항)

#169

💬 기타 (선택 사항)

리뷰어에게 전달하고 싶은 추가 정보나 궁금한 점이 있다면 작성해주세요.

@wlswnsdn wlswnsdn self-assigned this Jan 25, 2026
@wlswnsdn wlswnsdn added the 🌎 인프라 인프라 관련 label Jan 25, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @wlswnsdn, 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!

이 풀 리퀘스트는 애플리케이션의 로깅 시스템을 개선하여 개발 및 프로덕션 환경 모두에서 더 효율적이고 일관된 로그 관리를 가능하게 합니다. 프로덕션 환경에서는 구조화된 JSON 로그를 통해 로그 분석 및 모니터링을 용이하게 하고, 개발 환경에서는 색상 로그를 통해 개발자의 가독성을 높여 디버깅 경험을 향상시킵니다. 이는 애플리케이션의 전반적인 관찰 가능성을 높이고 문제 해결 시간을 단축하는 데 기여합니다.

Highlights

  • 새로운 로깅 설정 파일 추가: 애플리케이션의 로깅 설정을 중앙에서 관리하는 core/config/logging_config.py 파일이 새로 추가되었습니다.
  • 환경별 로깅 포맷 적용: ENV 환경 변수가 "prod"일 경우 JSON 포맷으로, 그 외 환경에서는 가독성을 높인 색상 포맷으로 로그를 출력하도록 설정되었습니다.
  • 기존 로깅 방식 대체: logging.basicConfig 호출이 새로 정의된 setup_logging() 함수로 대체되어, 애플리케이션 전반에 걸쳐 일관된 로깅 설정을 적용합니다.
  • print 문 로거로 대체: main.py 파일의 시작/종료 이벤트 핸들러에서 사용되던 print() 문들이 이제 logger.info(), logger.error(), logger.warning() 호출로 변경되어 로깅 시스템을 통해 메시지를 출력합니다.
  • 의존성 추가: JSON 로깅을 위해 python-json-logger 라이브러리가 requirements.txt에 추가되었습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@github-actions

Copy link
Copy Markdown

🤖 Gemini AI 코드 리뷰

❌ Gemini API 호출 실패: 최대 재시도 횟수 초과


이 리뷰는 Gemini AI가 자동으로 생성했습니다. 참고용으로만 활용해주세요.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

이번 PR은 환경에 따라 다른 포맷(JSON 또는 색상)으로 로그를 기록하도록 로깅 설정을 중앙화하는 중요한 개선 작업을 포함하고 있습니다. logging_config.py 파일을 추가하여 로깅 설정을 분리하고, 기존의 print문과 logging.basicConfig 호출을 새로운 setup_logging 함수로 대체한 점이 좋습니다.

몇 가지 개선점을 제안했습니다. CustomJsonFormatter에서 import 위치를 조정하고, 더 정확한 타임스탬프를 사용하도록 수정하여 성능과 정확성을 높일 수 있습니다. 또한, 사용되지 않는 fmt 인자를 제거하여 코드의 명확성을 향상시키는 것을 제안했습니다.

전반적으로 코드의 유지보수성과 관찰 가능성을 높이는 훌륭한 변경이라고 생각합니다.

Comment thread core/config/logging_config.py Outdated
Comment on lines +12 to +21
def format(self, record):
import json
log_dict = {
'@timestamp': datetime.now(KST).isoformat(),
'message': record.getMessage(),
'logger_name': record.name,
'thread_name': record.threadName,
'level': record.levelname
}
return json.dumps(log_dict, ensure_ascii=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

JSON 포매터를 좀 더 효율적이고 정확하게 개선할 수 있습니다.

  1. import json은 파일 상단으로 옮겨 매번 로그를 기록할 때마다 모듈을 다시 가져오지 않도록 하는 것이 좋습니다. 이는 성능에 영향을 줄 수 있습니다.
  2. @timestamp를 생성할 때 datetime.now() 대신 record.created를 사용하는 것이 더 정확합니다. record.created는 로그 이벤트가 발생한 실제 시간을 나타내지만, datetime.now()는 로그가 포매팅되는 시간을 나타냅니다. 이 둘 사이에는 미세한 차이가 있을 수 있으며, 디버깅 시에는 이벤트 발생 시각이 더 중요합니다.

아래와 같이 수정하는 것을 제안합니다. 그리고 import json을 파일 최상단으로 옮겨주세요.

Suggested change
def format(self, record):
import json
log_dict = {
'@timestamp': datetime.now(KST).isoformat(),
'message': record.getMessage(),
'logger_name': record.name,
'thread_name': record.threadName,
'level': record.levelname
}
return json.dumps(log_dict, ensure_ascii=False)
def format(self, record):
log_dict = {
'@timestamp': datetime.fromtimestamp(record.created, KST).isoformat(),
'message': record.getMessage(),
'logger_name': record.name,
'thread_name': record.threadName,
'level': record.levelname
}
return json.dumps(log_dict, ensure_ascii=False)

Comment thread core/config/logging_config.py Outdated
Comment on lines +48 to +50
formatter = CustomJsonFormatter(
fmt='%(message)s'
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

CustomJsonFormatterformat 메소드가 완전히 재정의되어 __init__으로 전달되는 fmt 인자가 사용되지 않고 있습니다. 코드의 명확성을 위해 이 인자를 제거하는 것이 좋습니다.

        formatter = CustomJsonFormatter()

@github-actions

Copy link
Copy Markdown

🤖 Gemini AI 코드 리뷰

❌ Gemini API 호출 실패: 최대 재시도 횟수 초과


이 리뷰는 Gemini AI가 자동으로 생성했습니다. 참고용으로만 활용해주세요.

@wlswnsdn

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot AI commented Jan 25, 2026

Copy link
Copy Markdown

@wlswnsdn I've opened a new pull request, #173, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI mentioned this pull request Jan 25, 2026
11 tasks
@github-actions

Copy link
Copy Markdown

🤖 Gemini AI 코드 리뷰

❌ Gemini API 호출 실패: 최대 재시도 횟수 초과


이 리뷰는 Gemini AI가 자동으로 생성했습니다. 참고용으로만 활용해주세요.

ENV 환경변수에 따라 로깅 포맷을 JSON 또는 색상 콘솔로 설정한다.
prod 환경에서는 JSON 포맷을 사용하여 로깅하고, 그 외 환경에서는 색상 콘솔 포맷을 사용한다.

uvicorn 로거에도 동일한 포맷을 적용하여 일관성을 유지한다.
기존 `pythonjsonlogger` 라이브러리 사용에서 `logging.Formatter`를 상속받아 JSON 로깅 포맷을 커스텀하도록 변경

- `@timestamp` 필드에 timezone 정보가 포함된 ISO 포맷 적용
- 개발 환경이 아닌 경우, JSON 포맷 로깅 적용
오토 스케일링 그룹의 최소 정상 인스턴스 비율을 50%에서 100%로 변경하여 안정적인 배포를 보장한다.
@wlswnsdn wlswnsdn force-pushed the feat/#169-json-logging branch from 091cd3a to 0a768cd Compare January 26, 2026 11:59
@github-actions

Copy link
Copy Markdown

🤖 Gemini AI 코드 리뷰

❌ Gemini API 호출 실패: 최대 재시도 횟수 초과


이 리뷰는 Gemini AI가 자동으로 생성했습니다. 참고용으로만 활용해주세요.

@wlswnsdn wlswnsdn merged commit 0e2045b into develop Jan 26, 2026
1 check passed
wlswnsdn added a commit that referenced this pull request Jan 27, 2026
* [FEAT] 에러 로그 발생 시 디코 웹훅 오도록 구현

* [FEAT] JSON 로깅 설정 추가 (#172)

* [FEAT] JSON 로깅 설정 추가

ENV 환경변수에 따라 로깅 포맷을 JSON 또는 색상 콘솔로 설정한다.
prod 환경에서는 JSON 포맷을 사용하여 로깅하고, 그 외 환경에서는 색상 콘솔 포맷을 사용한다.

uvicorn 로거에도 동일한 포맷을 적용하여 일관성을 유지한다.

* [FIX] JSON 로깅 포맷 커스텀 기능 추가

기존 `pythonjsonlogger` 라이브러리 사용에서 `logging.Formatter`를 상속받아 JSON 로깅 포맷을 커스텀하도록 변경

- `@timestamp` 필드에 timezone 정보가 포함된 ISO 포맷 적용
- 개발 환경이 아닌 경우, JSON 포맷 로깅 적용

* [FIX] ASG 최소 정상 인스턴스 비율 조정

오토 스케일링 그룹의 최소 정상 인스턴스 비율을 50%에서 100%로 변경하여 안정적인 배포를 보장한다.

* [FIX] Discord 로깅 시 예외 발생 처리 개선 (#175)

Discord 로깅 과정에서 예외가 발생했을 때, 문제 인지를 위해 오류 메시지를 stderr에 출력하도록 개선한다.

기존에는 JSON 로깅 관련 라이브러리를 사용했으나, 현재는 사용하지 않으므로 관련 설정을 제거한다.

---------

Co-authored-by: changmin <ml505050@naver.com>
Co-authored-by: chang min O <82094699+Ochangmin524@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌎 인프라 인프라 관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants