[Fix] batch에서 winston 도입 이후 로그가 출력되지 않는 문제 수정 - #107
Merged
Merged
Conversation
- NestFactory.create는 app.listen() 시점에만 버퍼 로그를 flush하는데, batch는 listen()을 호출하지 않아 winston 도입 이후 로그가 전혀 출력되지 않았음 - HTTP 서버가 필요 없으므로 createApplicationContext로 변경하여 useLogger 시점에 버퍼 로그가 자동 flush되도록 함 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: GNU-connect/Server-Node/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 개요
✨ 작업 내용
services/api/batch/src/main.ts:NestFactory.create→NestFactory.createApplicationContext로 변경 (bufferLogs: true는 유지)🔥 변경 이유
bufferLogs: true는 앱 초기화 중 로그를 버퍼에 쌓아 두었다가,useLogger로 지정한 로거(winston)로 flush하는 옵션NestFactory.create)은app.listen()콜백에서만 버퍼를 flush함 (nest-application.js). app 서비스는listen()을 호출해서 정상 출력됨app.init()만 호출하고listen()이 없어 버퍼가 한 번도 flush되지 않았고, Nest 시작 로그와BatchService의 warn/error가 모두 버퍼에 갇혔음. 수집 잡은 스케줄러로 계속 실행되어 로그만 안 보이는 상태였음listen()을 흉내 내는 대신,useLogger시점에 자동 flush하는createApplicationContext를 사용🧪 테스트
NODE_ENV=production, DB 없이 winston 배선만 검증한 프로브로 비교create+bufferLogs, flush 없음): 0줄bufferLogs끔: 10줄 /app.flushLogs()추가: 10줄 /createApplicationContext: 9줄nest build,eslint, jest 전체 통과 (17 suites, 83 tests)main.ts로 winston 출력 확인은 하지 못함. 로컬에 DB가 없어 초기화 단계에서 실패하며, 이때는 Nest 기본 로거 형식으로 출력됨. 배포 후docker compose logs batch에서[connect-gnu-batch]형식의 시작 로그가 나오는지 확인 필요listen()없이 스케줄러가 이벤트 루프를 유지하는 구조는 기존과 동일, 배포 워크플로의 20초 상태 확인으로 검증)🔗 관련 이슈
🤖 Generated with Claude Code
Summary by CodeRabbit