Pārlūkot izejas kodu

2023-11-9 处理printStackTrace() 变成log日志。

chaiyunlong 2 gadi atpakaļ
vecāks
revīzija
cfb05eb2bb

+ 5 - 1
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/utils/FileUtils.java

@@ -1,10 +1,14 @@
 package com.zd.base.files.bigupload.utils;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
 public class FileUtils {
+    private static final Logger log = LoggerFactory.getLogger(FileUtils.class);
     //删除文件夹
     public static void delFolder(String folderPath) {
         try {
@@ -13,7 +17,7 @@ public class FileUtils {
             File myFilePath = new File(filePath);
             myFilePath.delete(); //删除空文件夹
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("删除文件夹异常", e);
         }
     }
 

+ 6 - 1
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/contorller/UeditorController.java

@@ -3,6 +3,9 @@ package com.zd.base.files.ueditor.contorller;
 import com.alibaba.fastjson.JSONException;
 import com.zd.base.files.file.config.ResourcesConfig;
 import com.zd.base.files.ueditor.ActionEnter;
+import com.zd.common.core.utils.HttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -19,6 +22,8 @@ import java.io.PrintWriter;
 @Controller
 public class UeditorController {
 
+    private static final Logger log = LoggerFactory.getLogger(UeditorController.class);
+
     @RequestMapping("exec")
     public void getConfigInfo(HttpServletRequest request, HttpServletResponse response) {
         try {
@@ -30,7 +35,7 @@ public class UeditorController {
             writer.flush();
             writer.close();
         } catch (IOException | JSONException e) {
-            e.printStackTrace();
+            log.error("处理关于ueditor插件相关的请求异常", e);
         }
     }
 }

+ 6 - 1
zd-modules/zd-base/src/main/java/com/zd/base/message/service/impl/WechatMsgSendServiceImpl.java

@@ -3,6 +3,7 @@ package com.zd.base.message.service.impl;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.zd.base.files.bigupload.utils.FileUtils;
 import com.zd.base.message.domain.UserOpenId;
 import com.zd.base.message.properties.WeChatProperties;
 import com.zd.base.message.service.IUserOpenIdService;
@@ -14,6 +15,8 @@ import com.zd.common.core.template.TemplateResult;
 import com.zd.common.core.template.WxUserInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.BoundValueOperations;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -41,6 +44,8 @@ public class WechatMsgSendServiceImpl implements IWechatMsgSendService {
 
     private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
+    private static final Logger log = LoggerFactory.getLogger(WechatMsgSendServiceImpl.class);
+
     /**
      * 微信获取openId的返回值
      */
@@ -277,7 +282,7 @@ public class WechatMsgSendServiceImpl implements IWechatMsgSendService {
             }
             accessToken = ops.get();
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("查询token缓存异常", e);
         }
         return accessToken;
     }

+ 0 - 1
zd-modules/zd-base/src/main/java/com/zd/base/message/utils/SHA1.java

@@ -42,7 +42,6 @@ public class SHA1 {
             }
             return hexstr.toString();
         } catch (Exception e) {
-            e.printStackTrace();
             throw new SecurityException(e.getMessage());
         }
     }