Browse Source

log 生成 pdf 流程

yemeishu 3 ngày trước cách đây
mục cha
commit
d83d014625
2 tập tin đã thay đổi với 12 bổ sung2 xóa
  1. 9 2
      app/Services/ExamPdfExportService.php
  2. 3 0
      app/Services/PdfStorageService.php

+ 9 - 2
app/Services/ExamPdfExportService.php

@@ -35,8 +35,9 @@ class ExamPdfExportService
      */
     public function generateExamPdf(string $paperId): ?string
     {
+        Log::info('generateExamPdf 开始:', ['paper_id' => $paperId]);
         $url = $this->renderAndStoreExamPdf($paperId, includeAnswer: false, suffix: 'exam');
-
+        Log::info('generateExamPdf url 生成结果:', ['paper_id' => $paperId, 'url' => $url]);
         // 如果生成成功,将 URL 写入数据库
         if ($url) {
             $this->savePdfUrlToDatabase($paperId, 'exam_pdf_url', $url);
@@ -50,8 +51,9 @@ class ExamPdfExportService
      */
     public function generateGradingPdf(string $paperId): ?string
     {
+        Log::info('generateGradingPdf 开始:', ['paper_id' => $paperId]);
         $url = $this->renderAndStoreExamPdf($paperId, includeAnswer: true, suffix: 'grading', useGradingView: true);
-
+        Log::info('generateGradingPdf url 生成结果:', ['paper_id' => $paperId, 'url' => $url]);
         // 如果生成成功,将 URL 写入数据库
         if ($url) {
             $this->savePdfUrlToDatabase($paperId, 'grading_pdf_url', $url);
@@ -147,6 +149,11 @@ class ExamPdfExportService
 
             $pdfBinary = $this->buildPdf($html);
             if (!$pdfBinary) {
+                Log::error('ExamPdfExportService: buildPdf为空', [
+                    'paper_id' => $paperId,
+                    'include_answer' => $includeAnswer,
+                    'use_grading_view' => $useGradingView,
+                ]);
                 return null;
             }
 

+ 3 - 0
app/Services/PdfStorageService.php

@@ -105,6 +105,9 @@ class PdfStorageService
      */
     private function putChunsun(string $path, string $binary): ?string
     {
+        Log::info('PdfStorageService: Chunsun上传开始', [
+            'path' => $path,
+        ]);
         $uploadUrl = env('CHUNSUN_UPLOAD_URL', 'https://crmapi.dcjxb.yunzhixue.cn/file/upload');
 
         try {