Browse Source

增加日志

xueyiming 2 months ago
parent
commit
4328240ca9

+ 4 - 0
tencent-ad-server/src/main/java/com/tzld/piaoquan/tencentad/service/impl/FfmpegUtilServiceImpl.java

@@ -31,6 +31,8 @@ public class FfmpegUtilServiceImpl implements FfmpegUtilService {
                 || StringUtils.isEmpty(fetchKeyFramesParam.getTimestamp())) {
             return CommonResponse.create(500, "参数错误");
         }
+        log.info("fetchKeyFramesParam={}", fetchKeyFramesParam);
+        log.info("imagePath={}", imagePath);
         String imageFolder = imagePath + "/" + "timeTarget";
         File dir = new File(imageFolder);
         if (!dir.exists()) {
@@ -40,11 +42,13 @@ public class FfmpegUtilServiceImpl implements FfmpegUtilService {
 
             }
         }
+
         String imagePath = imageFolder + "/" + UUID.randomUUID() + ".jpg";
         String target = "long_articles/image";
 
         FfmpegUtil.getTargetTimeThumbnail(fetchKeyFramesParam.getUrl(), imagePath, fetchKeyFramesParam.getTimestamp());
         String imageUrl = OSSUploader.uploadToOSS(target, imagePath);
+        log.info("imageUrl={}", imageUrl);
         Path pathToDelete = Paths.get(imagePath);
         try {
             // 使用 Files.walkFileTree 删除文件夹及其内容

+ 6 - 2
tencent-ad-server/src/main/java/com/tzld/piaoquan/tencentad/utils/OSSUploader.java

@@ -3,10 +3,12 @@ package com.tzld.piaoquan.tencentad.utils;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.PutObjectRequest;
+import lombok.extern.slf4j.Slf4j;
 
 import java.io.File;
 import java.util.UUID;
 
+@Slf4j
 public class OSSUploader {
 
     private static final String ACCESS_KEY_ID = "LTAIP6x1l3DXfSxm"; // 填写您的 Access Key ID
@@ -27,11 +29,12 @@ public class OSSUploader {
             ossClient.putObject(putObjectRequest);
             return "https://rescdn.yishihui.com/" + ossVideoKey;
         } catch (Exception e) {
-            return null;
+            log.info("uploadToOSS error", e);
         } finally {
             // 关闭 OSSClient
             ossClient.shutdown();
         }
+        return null;
     }
 
     public static String uploadToOSS(String target, String localVideoPath) {
@@ -47,11 +50,12 @@ public class OSSUploader {
             ossClient.putObject(putObjectRequest);
             return ossVideoKey;
         } catch (Exception e) {
-            return null;
+            log.info("uploadToOSS error", e);
         } finally {
             // 关闭 OSSClient
             ossClient.shutdown();
         }
+        return null;
     }
 
     public static void main(String[] args) {