Skip to content

feat(report): 리포트 생성 로그 기록 추가#180

Merged
1Seob merged 10 commits into
developfrom
feat/report-generation-log
Jun 17, 2026
Merged

feat(report): 리포트 생성 로그 기록 추가#180
1Seob merged 10 commits into
developfrom
feat/report-generation-log

Conversation

@1Seob

@1Seob 1Seob commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

📝 요약(Summary)

개요

리포트 생성 과정에서 발생하는 성공, 실패, 외부 LLM 오류를 공통 로그로 추적할 수 있도록 리포트 생성 로그 구조를 추가했습니다.

이번 변경으로 일간, 주간, 월간, 월간 V2, 유형 리포트 생성 단계별 상태를 동일한 테이블과 서비스로 기록할 수 있습니다.

주요 변경 사항

1. 리포트 생성 로그 저장 구조 추가

  • report_generation_logs 테이블 추가
  • ReportGenerationLog 엔티티 추가
  • 리포트 타입, 리포트 ID, 생성 단계, 상태, LLM 제공자, 모델명, 오류 코드, 예외 클래스, HTTP 상태, 외부 오류 코드, 소요 시간 저장
  • ReportGenerationType, ReportGenerationStep, ReportGenerationLogStatus enum 추가
  • 로그 조회용 ReportGenerationLogRepository 추가

2. 로그 기록 서비스 추가

  • ReportGenerationLogService 추가
  • 생성 시작, 성공, 실패 상태 전이 처리
  • 실패 시 raw error message는 저장하지 않고 오류 코드, 예외 클래스, HTTP 상태, 외부 오류 코드만 저장
  • 로그 저장 실패가 리포트 생성 자체를 방해하지 않도록 ReportGenerationLogRecorder 추가

3. 외부 LLM 오류 분류 개선

  • AiServiceUnavailableException에 외부 HTTP 상태와 외부 오류 코드 필드 추가
  • BusinessException, AiServiceException에 cause 기반 생성자 추가
  • LlmExceptionMapper 추가
  • WebClientResponseException, HttpStatusCodeException, RestClientResponseException에서 HTTP 상태를 추출해 로그에 기록
  • LLM 외부 오류 코드는 HTTP_{status} 형태로 저장

4. 리포트 생성 흐름에 로그 연결

  • 일간 리포트: 생성 단계 로그 연결
  • 주간 리포트: 생성, confirm 단계 로그 연결
  • 월간 리포트 V1: 생성, confirm 단계 로그 연결
  • 월간 리포트 V2: 텍스트 생성, 텍스트 confirm, 이미지 생성, 최종 confirm 단계 로그 연결
  • 유형 리포트: evidence cards, pattern extraction, type selection, content generation, confirm 단계 로그 연결

5. 테스트 추가

  • ReportGenerationLogService 단위 테스트 추가
  • ReportGenerationLogRepository 조회 테스트 추가

🔗 Related Issue

  • Closes:

💬 공유사항

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • PR 제목을 커밋 메시지 컨벤션에 맞게 작성했습니다.

1Seob added 10 commits June 16, 2026 20:48
리포트 생성 로그를 조회·저장할 Repository를 추가하고, 생성 시작/성공/실패 상태를 별도 트랜잭션으로 기록하는 Service를 추가함. BusinessException
기반 에러 코드는 로그의 errorCode와 httpStatus로 변환해 저장
AI 예외에 원인 예외와 외부 HTTP 상태 및 외부 에러 코드를 보존하도록 확장함. 리포트 생성 로그에서 raw error_message 컬럼과 저장 로직을 제거해 민감정보 저장
가능성을 줄임.
일일 리포트 LLM 생성 단계에 로그 기록 연결, 입력·응답 문자 수 컬럼 제거로 로그 지표 단순화
WeeklyReportGenerationListener와 MonthlyReportGenerationListener의 LLM 생성 및 confirm 단계에
report_generation_logs 기록 추가, MonthlyReportGenerationListenerV2의 텍스트 생성·텍스트 confirm·이미지 생성·최종
confirm 단계별 로그 기록 추가
TypeReportGenerationListener의 evidence cards, pattern extraction, type selection, content
generation, confirm 단계에 ReportGenerationLogRecorder 기록 추가
LlmExceptionMapper 추가로 WebClientResponseException, HttpStatusCodeException,
RestClientResponseException의 HTTP status를 AiServiceUnavailableException에 보존하도록 처리, 리포트 LLM client 호출
실패 시 externalHttpStatus와 externalErrorCode를 report_generation_logs에 전달 가능하도록 정리
ReportGenerationLogRepository 조회 테스트와 ReportGenerationLogService 상태 변경 테스트 추가,
AiServiceUnavailableException의 externalHttpStatus와 externalErrorCode 반영 검증 추가
사용하지 않는 report_generation_logs.metadata 컬럼과 ReportGenerationLog metadata 필드 제거,
ReportGenerationLogService와 ReportGenerationLogRecorder의 start 시그니처 및 리포트 생성 로그 호출부 정리
report_generation_logs 테이블에서 사용 가능성이 낮은 user_id, status, error_code 기준 인덱스 제거, report_type과
report_id 기준 조회 인덱스만 유지
@coldsunn

Copy link
Copy Markdown
Collaborator

LGTM!

@1Seob 1Seob merged commit 77edb0b into develop Jun 17, 2026
1 check passed
@1Seob 1Seob deleted the feat/report-generation-log branch June 17, 2026 06:55
1Seob added a commit that referenced this pull request Jun 17, 2026
* feat(report): 리포트 생성 로그 기록 추가 (#180)

* feat(report): 리포트 생성 로그 테이블과 엔티티 추가

* feat(report): 리포트 생성 로그 Repository와 Service 추가

리포트 생성 로그를 조회·저장할 Repository를 추가하고, 생성 시작/성공/실패 상태를 별도 트랜잭션으로 기록하는 Service를 추가함. BusinessException
기반 에러 코드는 로그의 errorCode와 httpStatus로 변환해 저장

* feat(report): 리포트 생성 로그에 AI 외부 오류 정보 반영

AI 예외에 원인 예외와 외부 HTTP 상태 및 외부 에러 코드를 보존하도록 확장함. 리포트 생성 로그에서 raw error_message 컬럼과 저장 로직을 제거해 민감정보 저장
가능성을 줄임.

* feat(report): 일일 리포트 생성에 로그 기록 연결

일일 리포트 LLM 생성 단계에 로그 기록 연결, 입력·응답 문자 수 컬럼 제거로 로그 지표 단순화

* feat(report): 주간·월간 리포트 생성에 로그 기록 연결

WeeklyReportGenerationListener와 MonthlyReportGenerationListener의 LLM 생성 및 confirm 단계에
report_generation_logs 기록 추가, MonthlyReportGenerationListenerV2의 텍스트 생성·텍스트 confirm·이미지 생성·최종
confirm 단계별 로그 기록 추가

* feat(report): Type 리포트 생성 단계별로 로그 기록 연결

TypeReportGenerationListener의 evidence cards, pattern extraction, type selection, content
generation, confirm 단계에 ReportGenerationLogRecorder 기록 추가

* feat(ai): LLM 외부 오류 상태 기록 지원

LlmExceptionMapper 추가로 WebClientResponseException, HttpStatusCodeException,
RestClientResponseException의 HTTP status를 AiServiceUnavailableException에 보존하도록 처리, 리포트 LLM client 호출
실패 시 externalHttpStatus와 externalErrorCode를 report_generation_logs에 전달 가능하도록 정리

* test(report): 리포트 생성 로그 테스트 추가

ReportGenerationLogRepository 조회 테스트와 ReportGenerationLogService 상태 변경 테스트 추가,
AiServiceUnavailableException의 externalHttpStatus와 externalErrorCode 반영 검증 추가

* refactor(report): 리포트 생성 로그 metadata 제거

사용하지 않는 report_generation_logs.metadata 컬럼과 ReportGenerationLog metadata 필드 제거,
ReportGenerationLogService와 ReportGenerationLogRecorder의 start 시그니처 및 리포트 생성 로그 호출부 정리

* refactor(db): 리포트 생성 로그 인덱스 정리

report_generation_logs 테이블에서 사용 가능성이 낮은 user_id, status, error_code 기준 인덱스 제거, report_type과
report_id 기준 조회 인덱스만 유지

* fix(admin): 운영 서버 관리자 로그인 실패 대응 (#181)

관리자 비밀번호 비교 시 앞뒤 공백을 제거하고, 로그인 실패 기본 메시지에 HTTP 상태 코드를 표시하도록 수정
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.

2 participants