diff --git a/modules/agent/src/main/java/io/jpom/common/AgentExceptionHandler.java b/modules/agent/src/main/java/io/jpom/common/AgentExceptionHandler.java index 0de4be62a..fb2d66036 100644 --- a/modules/agent/src/main/java/io/jpom/common/AgentExceptionHandler.java +++ b/modules/agent/src/main/java/io/jpom/common/AgentExceptionHandler.java @@ -27,6 +27,7 @@ import cn.hutool.extra.servlet.ServletUtil; import cn.jiangzeyin.common.DefaultSystemLog; import cn.jiangzeyin.common.JsonMessage; import io.jpom.system.JpomRuntimeException; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -41,6 +42,7 @@ import javax.servlet.http.HttpServletResponse; * @since 2019/04/17 */ @ControllerAdvice +@Slf4j public class AgentExceptionHandler extends BaseExceptionHandler { /** @@ -52,7 +54,7 @@ public class AgentExceptionHandler extends BaseExceptionHandler { */ @ExceptionHandler({JpomRuntimeException.class, RuntimeException.class, Exception.class}) public void defExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e) { - DefaultSystemLog.getLog().error("controller " + request.getRequestURI(), e); + log.error("controller " + request.getRequestURI(), e); if (e instanceof JpomRuntimeException) { ServletUtil.write(response, JsonMessage.getString(500, e.getMessage()), MediaType.APPLICATION_JSON_VALUE); } else { @@ -69,7 +71,7 @@ public class AgentExceptionHandler extends BaseExceptionHandler { */ @ExceptionHandler({IllegalArgumentException.class, IllegalStateException.class, ValidateException.class}) public void paramExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e) { - DefaultSystemLog.getLog().error("controller " + request.getRequestURI(), e); + log.error("controller " + request.getRequestURI(), e); ServletUtil.write(response, JsonMessage.getString(405, e.getMessage()), MediaType.APPLICATION_JSON_VALUE); } } diff --git a/modules/agent/src/main/java/io/jpom/common/commander/AbstractProjectCommander.java b/modules/agent/src/main/java/io/jpom/common/commander/AbstractProjectCommander.java index 8611c2e8b..8c4af99e3 100644 --- a/modules/agent/src/main/java/io/jpom/common/commander/AbstractProjectCommander.java +++ b/modules/agent/src/main/java/io/jpom/common/commander/AbstractProjectCommander.java @@ -55,6 +55,7 @@ import io.jpom.util.CommandUtil; import io.jpom.util.FileUtils; import io.jpom.util.JvmUtil; import io.jpom.util.ProjectCommanderUtil; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.IOException; @@ -74,6 +75,7 @@ import java.util.jar.Manifest; * * @author Administrator */ +@Slf4j public abstract class AbstractProjectCommander { public static final String RUNNING_TAG = "running"; @@ -177,7 +179,7 @@ public abstract class AbstractProjectCommander { CommandUtil.asyncExeLocalCommand(file, command); } } catch (Exception e) { - DefaultSystemLog.getLog().error("执行命令失败", e); + log.error("执行命令失败", e); } }); } @@ -292,7 +294,7 @@ public abstract class AbstractProjectCommander { try { this.webHooks(nodeProjectInfoModel, javaCopyItem, type, other); } catch (Exception e) { - DefaultSystemLog.getLog().error("project webhook {}", e.getMessage()); + log.error("project webhook {}", e.getMessage()); } }); } @@ -406,7 +408,7 @@ public abstract class AbstractProjectCommander { return jarFile.getAbsolutePath() + "中没有找到对应的MainClass:" + mainClass; } } catch (Exception e) { - DefaultSystemLog.getLog().error("解析jar", e); + log.error("解析jar", e); return jarFile.getAbsolutePath() + " 解析错误:" + e.getMessage(); } return null; @@ -436,7 +438,7 @@ public abstract class AbstractProjectCommander { // 清空日志 String r = AbstractSystemCommander.getInstance().emptyLogFile(file); if (StrUtil.isNotEmpty(r)) { - DefaultSystemLog.getLog().info(r); + log.info(r); } return "ok"; } @@ -497,7 +499,7 @@ public abstract class AbstractProjectCommander { */ private String getLinuxPsStatus(String tag) { String execSystemCommand = CommandUtil.execSystemCommand("ps -ef | grep " + tag); - DefaultSystemLog.getLog().debug("getLinuxPsStatus {} {}", tag, execSystemCommand); + log.debug("getLinuxPsStatus {} {}", tag, execSystemCommand); List list = StrSplitter.splitTrim(execSystemCommand, StrUtil.LF, true); for (String item : list) { if (JvmUtil.checkCommandLineIsJpom(item, tag)) { @@ -588,7 +590,7 @@ public abstract class AbstractProjectCommander { return StrUtil.DASHED; } String tag = JvmUtil.parseCommandJpomTag(virtualMachine); - DefaultSystemLog.getLog().debug("getJpomNameByPid pid: {} {} {}", pid, tag, virtualMachine); + log.debug("getJpomNameByPid pid: {} {} {}", pid, tag, virtualMachine); ProjectInfoService projectInfoService = SpringUtil.getBean(ProjectInfoService.class); NodeProjectInfoModel item = projectInfoService.getItem(tag); if (item == null) { diff --git a/modules/agent/src/main/java/io/jpom/common/commander/AbstractTomcatCommander.java b/modules/agent/src/main/java/io/jpom/common/commander/AbstractTomcatCommander.java index 70595beb9..ee6b275e6 100644 --- a/modules/agent/src/main/java/io/jpom/common/commander/AbstractTomcatCommander.java +++ b/modules/agent/src/main/java/io/jpom/common/commander/AbstractTomcatCommander.java @@ -30,6 +30,7 @@ import io.jpom.common.commander.impl.LinuxTomcatCommander; import io.jpom.common.commander.impl.WindowsTomcatCommander; import io.jpom.model.data.TomcatInfoModel; import io.jpom.system.JpomRuntimeException; +import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.concurrent.TimeUnit; @@ -39,6 +40,7 @@ import java.util.concurrent.TimeUnit; * * @author LF */ +@Slf4j public abstract class AbstractTomcatCommander { private static AbstractTomcatCommander abstractTomcatCommander; @@ -107,7 +109,7 @@ public abstract class AbstractTomcatCommander { } protected void exec(String command, boolean close) { - DefaultSystemLog.getLog().info(command); + log.info(command); try { // 执行命令 Process process = Runtime.getRuntime().exec(command); @@ -119,7 +121,7 @@ public abstract class AbstractTomcatCommander { process.destroy(); } } catch (IOException | InterruptedException e) { - DefaultSystemLog.getLog().error("tomcat执行名称失败", e); + log.error("tomcat执行名称失败", e); } } } diff --git a/modules/agent/src/main/java/io/jpom/common/commander/impl/LinuxSystemCommander.java b/modules/agent/src/main/java/io/jpom/common/commander/impl/LinuxSystemCommander.java index d73197001..019d9ce5d 100644 --- a/modules/agent/src/main/java/io/jpom/common/commander/impl/LinuxSystemCommander.java +++ b/modules/agent/src/main/java/io/jpom/common/commander/impl/LinuxSystemCommander.java @@ -35,6 +35,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.common.commander.AbstractSystemCommander; import io.jpom.model.system.ProcessModel; import io.jpom.util.CommandUtil; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.util.ArrayList; @@ -44,6 +45,7 @@ import java.util.List; * @author jiangzeyin * @since 2019/4/16 */ +@Slf4j public class LinuxSystemCommander extends AbstractSystemCommander { @Override @@ -249,7 +251,7 @@ public class LinuxSystemCommander extends AbstractSystemCommander { CommandUtil.asyncExeLocalCommand(FileUtil.file(SystemUtil.getUserInfo().getHomeDir()), serviceName); return "ok"; } catch (Exception e) { - DefaultSystemLog.getLog().error("执行异常", e); + log.error("执行异常", e); return "执行异常:" + e.getMessage(); } } diff --git a/modules/agent/src/main/java/io/jpom/common/commander/impl/MacOsSystemCommander.java b/modules/agent/src/main/java/io/jpom/common/commander/impl/MacOsSystemCommander.java index 18b377e72..507a658a5 100644 --- a/modules/agent/src/main/java/io/jpom/common/commander/impl/MacOsSystemCommander.java +++ b/modules/agent/src/main/java/io/jpom/common/commander/impl/MacOsSystemCommander.java @@ -33,6 +33,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.common.commander.AbstractSystemCommander; import io.jpom.model.system.ProcessModel; import io.jpom.util.CommandUtil; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.util.ArrayList; @@ -41,6 +42,7 @@ import java.util.List; /** * @author User */ +@Slf4j public class MacOsSystemCommander extends AbstractSystemCommander { @Override @@ -67,7 +69,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander { jsonObject.put("memory", memory); } jsonObject.put("disk", getHardDisk()); - DefaultSystemLog.getLog().info("Mac OS monitor data: {}", jsonObject.toJSONString()); + log.info("Mac OS monitor data: {}", jsonObject.toJSONString()); return jsonObject; } @@ -84,7 +86,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander { return null; } double used = 0, free = 0; - DefaultSystemLog.getLog().debug("Mac Os mem info: {}", info); + log.debug("Mac Os mem info: {}", info); int index = info.indexOf(CharPool.COLON) + 1; String[] split = info.substring(index).split(StrUtil.COMMA); for (String str : split) { @@ -97,7 +99,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander { used = Convert.toDouble(value, 0.0); } } - DefaultSystemLog.getLog().debug("Mac OS mem: used: {}, unused: {}", used, free); + log.debug("Mac OS mem: used: {}, unused: {}", used, free); return String.format("%.2f", used / (used + free) * 100); } @@ -111,7 +113,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander { if (StrUtil.isEmpty(info)) { return null; } - DefaultSystemLog.getLog().debug("Mac Os cpu info: {}", info); + log.debug("Mac Os cpu info: {}", info); int i = info.indexOf(CharPool.COLON); String[] split = info.substring(i + 1).split(StrUtil.COMMA); for (String str : split) { @@ -152,9 +154,9 @@ public class MacOsSystemCommander extends AbstractSystemCommander { ProcessModel processModel; for (String item : list) { processModel = new ProcessModel(); - DefaultSystemLog.getLog().debug("process item: {}", item); + log.debug("process item: {}", item); List values = StrSplitter.splitTrim(item, StrUtil.SPACE, true); - //DefaultSystemLog.getLog().debug(JSON.toJSONString(values)); + //log.debug(JSON.toJSONString(values)); processModel.setPid(Convert.toInt(values.get(0), 0)); //processModel.setPort(values.get(6)); processModel.setCommand(values.get(1)); @@ -228,7 +230,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander { CommandUtil.asyncExeLocalCommand(FileUtil.file(SystemUtil.getUserInfo().getHomeDir()), serviceName); return "ok"; } catch (Exception e) { - DefaultSystemLog.getLog().error("执行异常", e); + log.error("执行异常", e); return "执行异常:" + e.getMessage(); } } diff --git a/modules/agent/src/main/java/io/jpom/controller/manage/ManageEditProjectController.java b/modules/agent/src/main/java/io/jpom/controller/manage/ManageEditProjectController.java index e11b8fdd1..5f1e38683 100644 --- a/modules/agent/src/main/java/io/jpom/controller/manage/ManageEditProjectController.java +++ b/modules/agent/src/main/java/io/jpom/controller/manage/ManageEditProjectController.java @@ -42,6 +42,7 @@ import io.jpom.model.data.NodeProjectInfoModel; import io.jpom.service.WhitelistDirectoryService; import io.jpom.service.manage.JdkInfoService; import io.jpom.system.ConfigBean; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -61,6 +62,7 @@ import java.util.List; */ @RestController @RequestMapping(value = "/manage/") +@Slf4j public class ManageEditProjectController extends BaseAgentController { private final WhitelistDirectoryService whitelistDirectoryService; @@ -282,7 +284,7 @@ public class ManageEditProjectController extends BaseAgentController { return JsonMessage.getString(200, "修改成功"); } } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); return JsonMessage.getString(500, "保存数据异常:" + e.getMessage()); } } @@ -371,7 +373,7 @@ public class ManageEditProjectController extends BaseAgentController { } return JsonMessage.getString(200, "删除成功!"); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); return JsonMessage.getString(500, "删除异常:" + e.getMessage()); } } diff --git a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileBackupController.java b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileBackupController.java index e1f506356..fed3b6b10 100644 --- a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileBackupController.java +++ b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileBackupController.java @@ -36,6 +36,7 @@ import io.jpom.model.data.NodeProjectInfoModel; import io.jpom.script.ProjectFileBackupUtil; import io.jpom.util.CommandUtil; import io.jpom.util.FileUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.GetMapping; @@ -59,6 +60,7 @@ import java.util.stream.Collectors; */ @RestController @RequestMapping(value = "/manage/file/") +@Slf4j public class ProjectFileBackupController extends BaseAgentController { /** @@ -132,7 +134,7 @@ public class ProjectFileBackupController extends BaseAgentController { } ServletUtil.write(response, file); } catch (Exception e) { - DefaultSystemLog.getLog().error("下载文件异常", e); + log.error("下载文件异常", e); ServletUtil.write(response, "下载文件异常:" + e.getMessage(), MediaType.TEXT_HTML_VALUE); } } diff --git a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileControl.java b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileControl.java index 99c8699e0..4af84b5f4 100644 --- a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileControl.java +++ b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectFileControl.java @@ -52,6 +52,7 @@ import io.jpom.service.manage.ConsoleService; import io.jpom.socket.ConsoleCommandOp; import io.jpom.system.AgentConfigBean; import io.jpom.util.*; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; @@ -73,6 +74,7 @@ import java.util.stream.Collectors; */ @RestController @RequestMapping(value = "/manage/file/") +@Slf4j public class ProjectFileControl extends BaseAgentController { private final ConsoleService consoleService; @@ -208,7 +210,7 @@ public class ProjectFileControl extends BaseAgentController { CompressionFileUtil.unCompress(file, lib); } finally { if (!FileUtil.del(file)) { - DefaultSystemLog.getLog().error("删除文件失败:" + file.getPath()); + log.error("删除文件失败:" + file.getPath()); } } } else { @@ -233,7 +235,7 @@ public class ProjectFileControl extends BaseAgentController { try { consoleService.execCommand(ConsoleCommandOp.restart, pim, javaCopyItem); } catch (Exception e) { - DefaultSystemLog.getLog().error("重启副本集失败", e); + log.error("重启副本集失败", e); } })); } @@ -275,7 +277,7 @@ public class ProjectFileControl extends BaseAgentController { } return true; } catch (Exception e) { - DefaultSystemLog.getLog().error("重复失败", e); + log.error("重复失败", e); // 完整重启,不再继续剩余的节点项目 return afterOpt != AfterOpt.Order_Must_Restart; } @@ -415,7 +417,7 @@ public class ProjectFileControl extends BaseAgentController { } ServletUtil.write(getResponse(), file); } catch (Exception e) { - DefaultSystemLog.getLog().error("下载文件异常", e); + log.error("下载文件异常", e); } return "下载失败。请刷新页面后重试"; } @@ -449,13 +451,13 @@ public class ProjectFileControl extends BaseAgentController { CompressionFileUtil.unCompress(downloadFile, file); } finally { if (!FileUtil.del(downloadFile)) { - DefaultSystemLog.getLog().error("删除文件失败:" + file.getPath()); + log.error("删除文件失败:" + file.getPath()); } } } return JsonMessage.getString(200, "下载成功文件大小:" + FileUtil.readableFileSize(downloadFile)); } catch (Exception e) { - DefaultSystemLog.getLog().error("下载远程文件异常", e); + log.error("下载远程文件异常", e); return JsonMessage.getString(500, "下载远程文件失败:" + e.getMessage()); } finally { ProjectFileBackupUtil.checkDiff(pim.getId(), pim.allLib(), backupId, pim.dslConfig()); diff --git a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectListController.java b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectListController.java index e0cb23ab2..42bf521a6 100644 --- a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectListController.java +++ b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectListController.java @@ -29,6 +29,7 @@ import io.jpom.common.BaseAgentController; import io.jpom.common.commander.AbstractProjectCommander; import io.jpom.model.RunMode; import io.jpom.model.data.NodeProjectInfoModel; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -46,6 +47,7 @@ import java.util.List; */ @RestController @RequestMapping(value = "/manage/") +@Slf4j public class ProjectListController extends BaseAgentController { /** @@ -93,7 +95,7 @@ public class ProjectListController extends BaseAgentController { List nodeProjectInfoModels = projectInfoService.list(); return JsonMessage.getString(200, "查询成功!", nodeProjectInfoModels); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); return JsonMessage.getString(500, "查询异常:" + e.getMessage()); } } diff --git a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectStatusController.java b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectStatusController.java index f9666336c..aeb474db9 100644 --- a/modules/agent/src/main/java/io/jpom/controller/manage/ProjectStatusController.java +++ b/modules/agent/src/main/java/io/jpom/controller/manage/ProjectStatusController.java @@ -36,6 +36,7 @@ import io.jpom.service.manage.ConsoleService; import io.jpom.socket.ConsoleCommandOp; import io.jpom.util.CommandUtil; import io.jpom.util.JvmUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -52,6 +53,7 @@ import java.util.List; */ @RestController @RequestMapping(value = "/manage/") +@Slf4j public class ProjectStatusController extends BaseAgentController { private final ConsoleService consoleService; @@ -77,7 +79,7 @@ public class ProjectStatusController extends BaseAgentController { try { pid = AbstractProjectCommander.getInstance().getPid(nodeProjectInfoModel, null); } catch (Exception e) { - DefaultSystemLog.getLog().error("获取项目pid 失败", e); + log.error("获取项目pid 失败", e); } if (pid <= 0) { Assert.state(JvmUtil.jpsNormal, "当前服务器 jps 命令异常,请检查 jdk 是否完整,以及 java 环境变量是否配置正确"); @@ -125,7 +127,7 @@ public class ProjectStatusController extends BaseAgentController { NodeProjectInfoModel projectInfoServiceItem = projectInfoService.getItem(item); pid = AbstractProjectCommander.getInstance().getPid(projectInfoServiceItem, null); } catch (Exception e) { - DefaultSystemLog.getLog().error("获取端口错误", e); + log.error("获取端口错误", e); continue; } if (pid <= 0) { @@ -175,7 +177,7 @@ public class ProjectStatusController extends BaseAgentController { continue; } } catch (Exception e) { - DefaultSystemLog.getLog().error("获取端口错误", e); + log.error("获取端口错误", e); continue; } itemObj = new JSONObject(); @@ -205,7 +207,7 @@ public class ProjectStatusController extends BaseAgentController { } return JsonMessage.getString(201, "重启项目失败:" + result); } catch (Exception e) { - DefaultSystemLog.getLog().error("获取项目pid 失败", e); + log.error("获取项目pid 失败", e); result = "error:" + e.getMessage(); return JsonMessage.getString(500, "重启项目异常:" + result); } @@ -227,7 +229,7 @@ public class ProjectStatusController extends BaseAgentController { } return JsonMessage.getString(201, "关闭项目失败:" + result); } catch (Exception e) { - DefaultSystemLog.getLog().error("获取项目pid 失败", e); + log.error("获取项目pid 失败", e); result = "error:" + e.getMessage(); return JsonMessage.getString(500, "关闭项目异常:" + result); } @@ -248,7 +250,7 @@ public class ProjectStatusController extends BaseAgentController { } return JsonMessage.getString(201, "启动项目失败:" + result); } catch (Exception e) { - DefaultSystemLog.getLog().error("获取项目pid 失败", e); + log.error("获取项目pid 失败", e); result = "error:" + e.getMessage(); return JsonMessage.getString(500, "启动项目异常:" + result); } diff --git a/modules/agent/src/main/java/io/jpom/controller/manage/log/LogBackController.java b/modules/agent/src/main/java/io/jpom/controller/manage/log/LogBackController.java index 13102dffe..6d7458d19 100644 --- a/modules/agent/src/main/java/io/jpom/controller/manage/log/LogBackController.java +++ b/modules/agent/src/main/java/io/jpom/controller/manage/log/LogBackController.java @@ -31,6 +31,7 @@ import io.jpom.common.BaseAgentController; import io.jpom.common.commander.AbstractProjectCommander; import io.jpom.model.data.NodeProjectInfoModel; import io.jpom.util.FileUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -48,6 +49,7 @@ import java.util.List; */ @RestController @RequestMapping(value = "manage/log") +@Slf4j public class LogBackController extends BaseAgentController { @RequestMapping(value = "logSize", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @@ -76,7 +78,7 @@ public class LogBackController extends BaseAgentController { } return JsonMessage.getString(201, "重置失败:" + msg); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); return JsonMessage.getString(500, "重置日志失败"); } } @@ -113,7 +115,7 @@ public class LogBackController extends BaseAgentController { return "没有对应文件"; } } catch (Exception e) { - DefaultSystemLog.getLog().error("下载文件异常", e); + log.error("下载文件异常", e); } return "下载失败。请刷新页面后重试"; } diff --git a/modules/agent/src/main/java/io/jpom/controller/monitor/InternalController.java b/modules/agent/src/main/java/io/jpom/controller/monitor/InternalController.java index 547eb5973..bb10bf61e 100644 --- a/modules/agent/src/main/java/io/jpom/controller/monitor/InternalController.java +++ b/modules/agent/src/main/java/io/jpom/controller/monitor/InternalController.java @@ -36,6 +36,7 @@ import io.jpom.model.system.NetstatModel; import io.jpom.model.system.ProcessModel; import io.jpom.system.AgentConfigBean; import io.jpom.util.CommandUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -53,6 +54,7 @@ import java.util.List; */ @RestController @RequestMapping(value = "/manage/") +@Slf4j public class InternalController extends BaseAgentController { /** @@ -174,7 +176,7 @@ public class InternalController extends BaseAgentController { // jsonObject.put("nonHeapCommitted", FileUtil.readableFileSize(nonCommitted)); // return jsonObject; // } catch (Exception e) { -// DefaultSystemLog.getLog().error(e.getMessage(), e); +// log.error(e.getMessage(), e); // } // return null; // } @@ -202,7 +204,7 @@ public class InternalController extends BaseAgentController { CommandUtil.execSystemCommand(command); downLoad(getResponse(), fileName); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); // getResponse().sendRedirect("internal?tag=" + tag); } return JsonMessage.getString(200, ""); @@ -230,7 +232,7 @@ public class InternalController extends BaseAgentController { CommandUtil.execSystemCommand(command); downLoad(getResponse(), fileName); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); // getResponse().sendRedirect("internal?tag=" + tag); } return JsonMessage.getString(200, ""); diff --git a/modules/agent/src/main/java/io/jpom/controller/system/CertificateController.java b/modules/agent/src/main/java/io/jpom/controller/system/CertificateController.java index 7892437e3..f96b24016 100644 --- a/modules/agent/src/main/java/io/jpom/controller/system/CertificateController.java +++ b/modules/agent/src/main/java/io/jpom/controller/system/CertificateController.java @@ -36,6 +36,7 @@ import io.jpom.model.data.CertModel; import io.jpom.service.WhitelistDirectoryService; import io.jpom.service.system.CertService; import io.jpom.system.AgentConfigBean; +import lombok.extern.slf4j.Slf4j; import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; @@ -58,6 +59,7 @@ import java.util.zip.ZipFile; */ @RestController @RequestMapping(value = "/system/certificate") +@Slf4j public class CertificateController extends BaseAgentController { @Resource @@ -115,7 +117,7 @@ public class CertificateController extends BaseAgentController { certService.updateItem(certModel); } } catch (Exception e) { - DefaultSystemLog.getLog().error("证书文件", e); + log.error("证书文件", e); return JsonMessage.getString(400, "解析证书文件失败:" + e.getMessage()); } return JsonMessage.getString(200, "提交成功"); diff --git a/modules/agent/src/main/java/io/jpom/controller/system/NginxController.java b/modules/agent/src/main/java/io/jpom/controller/system/NginxController.java index f3358ce5e..6beec43a0 100644 --- a/modules/agent/src/main/java/io/jpom/controller/system/NginxController.java +++ b/modules/agent/src/main/java/io/jpom/controller/system/NginxController.java @@ -44,6 +44,7 @@ import io.jpom.service.WhitelistDirectoryService; import io.jpom.service.system.NginxService; import io.jpom.util.CommandUtil; import io.jpom.util.StringUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -65,6 +66,7 @@ import java.util.List; */ @RestController @RequestMapping("/system/nginx") +@Slf4j public class NginxController extends BaseAgentController { @Resource @@ -183,13 +185,13 @@ public class NginxController extends BaseAgentController { } } } catch (IOException e) { - DefaultSystemLog.getLog().error("解析失败", e); + log.error("解析失败", e); return JsonMessage.getString(500, "解析失败"); } try { FileUtil.writeString(context, file, CharsetUtil.UTF_8); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); return JsonMessage.getString(400, "操作失败:" + e.getMessage()); } String msg = this.reloadNginx(); @@ -202,11 +204,11 @@ public class NginxController extends BaseAgentController { String format = StrUtil.format("{} -s reload", serviceName); String msg = CommandUtil.execSystemCommand(format); if (StrUtil.isNotEmpty(msg)) { - DefaultSystemLog.getLog().info(msg); + log.info(msg); return "(" + msg + ")"; } } catch (Exception e) { - DefaultSystemLog.getLog().error("reload nginx error", e); + log.error("reload nginx error", e); } return StrUtil.EMPTY; } @@ -267,7 +269,7 @@ public class NginxController extends BaseAgentController { FileUtil.rename(file, file.getName() + "_back", false, true); } } catch (Exception e) { - DefaultSystemLog.getLog().error("删除nginx", e); + log.error("删除nginx", e); return JsonMessage.getString(400, "操作失败:" + e.getMessage()); } } diff --git a/modules/agent/src/main/java/io/jpom/controller/system/SystemConfigController.java b/modules/agent/src/main/java/io/jpom/controller/system/SystemConfigController.java index 1fc061615..36f78fbd2 100644 --- a/modules/agent/src/main/java/io/jpom/controller/system/SystemConfigController.java +++ b/modules/agent/src/main/java/io/jpom/controller/system/SystemConfigController.java @@ -36,6 +36,7 @@ import io.jpom.common.BaseAgentController; import io.jpom.common.Const; import io.jpom.common.JpomManifest; import io.jpom.system.ExtConfigBean; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.env.YamlPropertySourceLoader; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; @@ -56,6 +57,7 @@ import java.nio.charset.StandardCharsets; */ @RestController @RequestMapping(value = "system") +@Slf4j public class SystemConfigController extends BaseAgentController { @RequestMapping(value = "getConfig.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @@ -79,7 +81,7 @@ public class SystemConfigController extends BaseAgentController { ByteArrayResource resource = new ByteArrayResource(content.replace("\t", " ").getBytes(StandardCharsets.UTF_8)); yamlPropertySourceLoader.load("test", resource); } catch (Exception e) { - DefaultSystemLog.getLog().warn("内容格式错误,请检查修正", e); + log.warn("内容格式错误,请检查修正", e); return JsonMessage.getString(500, "内容格式错误,请检查修正:" + e.getMessage()); } if (JpomManifest.getInstance().isDebug()) { diff --git a/modules/agent/src/main/java/io/jpom/controller/tomcat/TomcatManageController.java b/modules/agent/src/main/java/io/jpom/controller/tomcat/TomcatManageController.java index e79a51180..a210b6aca 100644 --- a/modules/agent/src/main/java/io/jpom/controller/tomcat/TomcatManageController.java +++ b/modules/agent/src/main/java/io/jpom/controller/tomcat/TomcatManageController.java @@ -41,6 +41,7 @@ import io.jpom.service.manage.TomcatManageService; import io.jpom.socket.AgentFileTailWatcher; import io.jpom.util.LayuiTreeUtil; import io.jpom.util.StringUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -56,6 +57,7 @@ import java.util.concurrent.TimeUnit; */ @RestController @RequestMapping(value = "/tomcat/") +@Slf4j public class TomcatManageController extends BaseAgentController { @Resource @@ -336,7 +338,7 @@ public class TomcatManageController extends BaseAgentController { } ServletUtil.write(getResponse(), file); } catch (Exception e) { - DefaultSystemLog.getLog().error("下载文件异常", e); + log.error("下载文件异常", e); } return "下载失败。请刷新页面后重试"; } diff --git a/modules/agent/src/main/java/io/jpom/model/data/CertModel.java b/modules/agent/src/main/java/io/jpom/model/data/CertModel.java index b4a525b63..819a3272d 100644 --- a/modules/agent/src/main/java/io/jpom/model/data/CertModel.java +++ b/modules/agent/src/main/java/io/jpom/model/data/CertModel.java @@ -36,6 +36,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.model.BaseModel; import io.jpom.service.system.CertService; import io.jpom.system.JpomRuntimeException; +import lombok.extern.slf4j.Slf4j; import java.io.InputStream; import java.security.PrivateKey; @@ -48,6 +49,7 @@ import java.util.Date; * * @author Arno */ +@Slf4j public class CertModel extends BaseModel { private static final String KEY = "Jpom 管理系统"; @@ -207,7 +209,7 @@ public class CertModel extends BaseModel { jsonObject.put("keyPath", key); return jsonObject; } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); } finally { IoUtil.close(inputStream); } diff --git a/modules/agent/src/main/java/io/jpom/model/data/UploadFileModel.java b/modules/agent/src/main/java/io/jpom/model/data/UploadFileModel.java index 832f1a2c9..7bc70be18 100644 --- a/modules/agent/src/main/java/io/jpom/model/data/UploadFileModel.java +++ b/modules/agent/src/main/java/io/jpom/model/data/UploadFileModel.java @@ -26,6 +26,7 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.model.BaseModel; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.FileOutputStream; @@ -34,6 +35,7 @@ import java.io.IOException; /** * @author lf */ +@Slf4j public class UploadFileModel extends BaseModel { private long size = 0; private long completeSize = 0; @@ -80,7 +82,7 @@ public class UploadFileModel extends BaseModel { fileOutputStream.write(data); fileOutputStream.flush(); } catch (IOException e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); } } diff --git a/modules/agent/src/main/java/io/jpom/model/system/ProcessModel.java b/modules/agent/src/main/java/io/jpom/model/system/ProcessModel.java index 9555bcc79..cafe17c64 100644 --- a/modules/agent/src/main/java/io/jpom/model/system/ProcessModel.java +++ b/modules/agent/src/main/java/io/jpom/model/system/ProcessModel.java @@ -26,6 +26,7 @@ import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.common.commander.AbstractProjectCommander; import io.jpom.model.BaseJsonModel; +import lombok.extern.slf4j.Slf4j; import java.io.IOException; @@ -35,6 +36,7 @@ import java.io.IOException; * @author jiangzeyin * @since 2019/4/15 */ +@Slf4j public class ProcessModel extends BaseJsonModel { /** * 进程id @@ -123,7 +125,7 @@ public class ProcessModel extends BaseJsonModel { String jpomName = AbstractProjectCommander.getInstance().getJpomNameByPid(pid); this.setJpomName(jpomName); } catch (IOException e) { - DefaultSystemLog.getLog().error("解析进程失败", e); + log.error("解析进程失败", e); } } } diff --git a/modules/agent/src/main/java/io/jpom/script/DslScriptBuilder.java b/modules/agent/src/main/java/io/jpom/script/DslScriptBuilder.java index 0ec5ec4bc..a2a138039 100644 --- a/modules/agent/src/main/java/io/jpom/script/DslScriptBuilder.java +++ b/modules/agent/src/main/java/io/jpom/script/DslScriptBuilder.java @@ -38,6 +38,7 @@ import io.jpom.service.script.NodeScriptServer; import io.jpom.system.ExtConfigBean; import io.jpom.util.CommandUtil; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.util.ArrayList; @@ -52,6 +53,7 @@ import java.util.Map; * @since 2022/1/15 */ @Setter +@Slf4j public class DslScriptBuilder extends BaseRunScript implements Runnable { @@ -75,7 +77,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable { List command = StrUtil.splitTrim(args, StrUtil.SPACE); command.add(0, script); command.add(0, CommandUtil.EXECUTE_PREFIX); - DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE)); + log.debug(CollUtil.join(command, StrUtil.SPACE)); if (environment != null) { processBuilder.environment().putAll(environment); } @@ -98,7 +100,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable { // this.handle("execute done:" + waitFor + " time:" + DateUtil.now()); } catch (Exception e) { - DefaultSystemLog.getLog().error("执行异常", e); + log.error("执行异常", e); String msg = "执行异常:" + e.getMessage(); this.end(msg); } @@ -128,7 +130,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable { result.add(0, "" + waitFor); return CollUtil.join(result, StrUtil.CRLF); } catch (Exception e) { - DefaultSystemLog.getLog().error("执行异常", e); + log.error("执行异常", e); return "执行异常:" + e.getMessage(); } finally { this.close(); diff --git a/modules/agent/src/main/java/io/jpom/script/ScriptProcessBuilder.java b/modules/agent/src/main/java/io/jpom/script/ScriptProcessBuilder.java index 7e8251da0..143eb4198 100644 --- a/modules/agent/src/main/java/io/jpom/script/ScriptProcessBuilder.java +++ b/modules/agent/src/main/java/io/jpom/script/ScriptProcessBuilder.java @@ -129,7 +129,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { try { SocketSessionUtil.send(session, line); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } }); } @@ -188,7 +188,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { this.end(jsonObject.toString()); this.handle("execute done:" + waitFor + " time:" + DateUtil.now()); } catch (Exception e) { - DefaultSystemLog.getLog().error("执行异常", e); + log.error("执行异常", e); this.end("执行异常:" + e.getMessage()); } finally { this.close(); @@ -208,7 +208,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { try { SocketSessionUtil.send(session, msg); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } iterator.remove(); } @@ -230,7 +230,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { try { SocketSessionUtil.send(session, line); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); iterator.remove(); } } diff --git a/modules/agent/src/main/java/io/jpom/service/WhitelistDirectoryService.java b/modules/agent/src/main/java/io/jpom/service/WhitelistDirectoryService.java index fc0a1be42..1262eb639 100644 --- a/modules/agent/src/main/java/io/jpom/service/WhitelistDirectoryService.java +++ b/modules/agent/src/main/java/io/jpom/service/WhitelistDirectoryService.java @@ -27,6 +27,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.model.data.AgentWhitelist; import io.jpom.system.AgentConfigBean; import io.jpom.util.JsonFileUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -39,6 +40,7 @@ import java.util.List; * @since 2019/2/28 */ @Service +@Slf4j public class WhitelistDirectoryService extends BaseDataService { /** @@ -54,7 +56,7 @@ public class WhitelistDirectoryService extends BaseDataService { } return jsonObject.toJavaObject(AgentWhitelist.class); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); } return new AgentWhitelist(); } diff --git a/modules/agent/src/main/java/io/jpom/service/system/NginxService.java b/modules/agent/src/main/java/io/jpom/service/system/NginxService.java index e791f059e..cb95983b0 100644 --- a/modules/agent/src/main/java/io/jpom/service/system/NginxService.java +++ b/modules/agent/src/main/java/io/jpom/service/system/NginxService.java @@ -40,6 +40,7 @@ import io.jpom.service.WhitelistDirectoryService; import io.jpom.system.AgentConfigBean; import io.jpom.util.JsonFileUtil; import io.jpom.util.StringUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.io.File; @@ -54,6 +55,7 @@ import java.util.stream.Collectors; * @author Arno */ @Service +@Slf4j public class NginxService extends BaseDataService { private final WhitelistDirectoryService whitelistDirectoryService; @@ -106,7 +108,7 @@ public class NginxService extends BaseDataService { jsonObject.putAll(data); } } catch (IOException e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); } return jsonObject; @@ -296,7 +298,7 @@ public class NginxService extends BaseDataService { } } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); } return jsonObject; } diff --git a/modules/agent/src/main/java/io/jpom/socket/AgentFileTailWatcher.java b/modules/agent/src/main/java/io/jpom/socket/AgentFileTailWatcher.java index 70ffaba51..4a0f510bc 100644 --- a/modules/agent/src/main/java/io/jpom/socket/AgentFileTailWatcher.java +++ b/modules/agent/src/main/java/io/jpom/socket/AgentFileTailWatcher.java @@ -25,6 +25,7 @@ package io.jpom.socket; import cn.hutool.core.io.FileUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.util.BaseFileTailWatcher; +import lombok.extern.slf4j.Slf4j; import javax.websocket.Session; import java.io.File; @@ -39,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; * @author jiangzeyin * @since 2019/3/16 */ +@Slf4j public class AgentFileTailWatcher extends BaseFileTailWatcher { private static final ConcurrentHashMap> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); @@ -60,14 +62,14 @@ public class AgentFileTailWatcher extends BaseFileTailWatcher { */ public static boolean addWatcher(File file, Session session) throws IOException { if (!FileUtil.isFile(file)) { - DefaultSystemLog.getLog().warn("文件不存在或者是目录:" + file.getPath()); + log.warn("文件不存在或者是目录:" + file.getPath()); return false; } AgentFileTailWatcher agentFileTailWatcher = CONCURRENT_HASH_MAP.computeIfAbsent(file, s -> { try { return new AgentFileTailWatcher<>(file); } catch (Exception e) { - DefaultSystemLog.getLog().error("创建文件监听失败", e); + log.error("创建文件监听失败", e); return null; } }); diff --git a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketConsoleHandle.java b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketConsoleHandle.java index e61d123f0..b6b383a8b 100644 --- a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketConsoleHandle.java +++ b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketConsoleHandle.java @@ -40,6 +40,7 @@ import io.jpom.service.manage.ProjectInfoService; import io.jpom.util.BaseFileTailWatcher; import io.jpom.util.FileSearchUtil; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.websocket.*; @@ -57,6 +58,7 @@ import java.util.function.Consumer; */ @ServerEndpoint(value = "/console") @Component +@Slf4j public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle { private static ProjectInfoService projectInfoService; @@ -82,12 +84,12 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle { SocketSessionUtil.send(session, "连接成功:" + nodeProjectInfoModel.getName()); } } catch (Exception e) { - DefaultSystemLog.getLog().error("socket 错误", e); + log.error("socket 错误", e); try { SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!")); session.close(); } catch (IOException e1) { - DefaultSystemLog.getLog().error(e1.getMessage(), e1); + log.error(e1.getMessage(), e1); } } } @@ -200,7 +202,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle { break; } } catch (Exception e) { - DefaultSystemLog.getLog().error("执行命令失败", e); + log.error("执行命令失败", e); SocketSessionUtil.send(session, "执行命令失败,详情如下:"); SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e)); return; @@ -217,7 +219,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle { if (resultData != null) { reqJson.putAll(resultData); reqJson.put("JPOM_MSG", "JPOM_MSG"); - DefaultSystemLog.getLog().info(reqJson.toString()); + log.info(reqJson.toString()); SocketSessionUtil.send(session, reqJson.toString()); } } @@ -268,7 +270,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle { }); SocketSessionUtil.send(session, resultMsg); } catch (Exception e) { - DefaultSystemLog.getLog().error("文件搜索失败", e); + log.error("文件搜索失败", e); try { SocketSessionUtil.send(session, "执行命令失败,详情如下:"); } catch (IOException ignored) { @@ -293,7 +295,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle { SocketSessionUtil.send(session, "监听文件失败,可能文件不存在"); } } catch (IOException io) { - DefaultSystemLog.getLog().error("监听日志变化", io); + log.error("监听日志变化", io); SocketSessionUtil.send(session, io.getMessage()); } } diff --git a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketScriptHandle.java b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketScriptHandle.java index bc4d7912b..9f5b440bd 100644 --- a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketScriptHandle.java +++ b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketScriptHandle.java @@ -31,6 +31,7 @@ import io.jpom.model.data.NodeScriptModel; import io.jpom.script.ScriptProcessBuilder; import io.jpom.service.script.NodeScriptServer; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.websocket.*; @@ -45,6 +46,7 @@ import java.io.IOException; */ @ServerEndpoint(value = "/script_run") @Component +@Slf4j public class AgentWebSocketScriptHandle extends BaseAgentWebSocketHandle { private NodeScriptServer nodeScriptServer; @@ -70,12 +72,12 @@ public class AgentWebSocketScriptHandle extends BaseAgentWebSocketHandle { } SocketSessionUtil.send(session, "连接成功:" + nodeScriptModel.getName()); } catch (Exception e) { - DefaultSystemLog.getLog().error("socket 错误", e); + log.error("socket 错误", e); try { SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!")); session.close(); } catch (IOException e1) { - DefaultSystemLog.getLog().error(e1.getMessage(), e1); + log.error(e1.getMessage(), e1); } } } @@ -125,7 +127,7 @@ public class AgentWebSocketScriptHandle extends BaseAgentWebSocketHandle { nodeScriptServer.updateItem(nodeScriptModel); json.put("code", 200); json.put("msg", "执行成功"); - DefaultSystemLog.getLog().info(json.toString()); + log.info(json.toString()); SocketSessionUtil.send(session, json.toString()); } diff --git a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketTomcatHandle.java b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketTomcatHandle.java index 389ba6946..21f1d52dc 100644 --- a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketTomcatHandle.java +++ b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketTomcatHandle.java @@ -33,6 +33,7 @@ import io.jpom.model.data.TomcatInfoModel; import io.jpom.service.manage.TomcatEditService; import io.jpom.system.WebAopLog; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.websocket.*; @@ -50,6 +51,7 @@ import java.util.concurrent.ConcurrentHashMap; */ @ServerEndpoint(value = "/tomcat_log") @Component +@Slf4j public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle { private TomcatEditService tomcatEditService; @@ -74,12 +76,12 @@ public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle { } SocketSessionUtil.send(session, "连接成功:" + (tomcatInfoModel == null ? "" : tomcatInfoModel.getName())); } catch (Exception e) { - DefaultSystemLog.getLog().error("socket 错误", e); + log.error("socket 错误", e); try { SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!")); session.close(); } catch (IOException e1) { - DefaultSystemLog.getLog().error(e1.getMessage(), e1); + log.error(e1.getMessage(), e1); } } } @@ -121,11 +123,11 @@ public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle { AgentFileTailWatcher.addWatcher(file, session); CACHE_FILE.put(session.getId(), file); } catch (IOException io) { - DefaultSystemLog.getLog().error("监听日志变化", io); + log.error("监听日志变化", io); SocketSessionUtil.send(session, io.getMessage()); } } catch (Exception e) { - DefaultSystemLog.getLog().error("执行命令失败", e); + log.error("执行命令失败", e); SocketSessionUtil.send(session, "执行命令失败,详情如下:"); SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e)); } @@ -139,11 +141,11 @@ public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle { try { AgentFileTailWatcher.addWatcher(file, session); } catch (IOException io) { - DefaultSystemLog.getLog().error("监听日志变化", io); + log.error("监听日志变化", io); SocketSessionUtil.send(session, io.getMessage()); } } catch (Exception e) { - DefaultSystemLog.getLog().error("执行命令失败", e); + log.error("执行命令失败", e); SocketSessionUtil.send(session, "执行命令失败,详情如下:"); SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e)); } diff --git a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketUpdateHandle.java b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketUpdateHandle.java index ddeb65724..ba3191c19 100644 --- a/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketUpdateHandle.java +++ b/modules/agent/src/main/java/io/jpom/socket/AgentWebSocketUpdateHandle.java @@ -36,6 +36,7 @@ import io.jpom.model.WebSocketMessageModel; import io.jpom.model.data.UploadFileModel; import io.jpom.system.AgentConfigBean; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.websocket.*; @@ -51,6 +52,7 @@ import java.util.Map; */ @ServerEndpoint(value = "/node_update") @Component +@Slf4j public class AgentWebSocketUpdateHandle extends BaseAgentWebSocketHandle { private static final Map UPLOAD_FILE_INFO = new HashMap<>(); @@ -123,7 +125,7 @@ public class AgentWebSocketUpdateHandle extends BaseAgentWebSocketHandle { JpomApplication.restart(); } catch (Exception e) { result = "重启失败" + e.getMessage(); - DefaultSystemLog.getLog().error("重启失败", e); + log.error("重启失败", e); } return result; } diff --git a/modules/agent/src/main/java/io/jpom/socket/BaseAgentWebSocketHandle.java b/modules/agent/src/main/java/io/jpom/socket/BaseAgentWebSocketHandle.java index 4dd29c7d3..4a489a9c9 100644 --- a/modules/agent/src/main/java/io/jpom/socket/BaseAgentWebSocketHandle.java +++ b/modules/agent/src/main/java/io/jpom/socket/BaseAgentWebSocketHandle.java @@ -31,6 +31,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.system.AgentAuthorize; import io.jpom.system.ConfigBean; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import javax.websocket.CloseReason; import javax.websocket.Session; @@ -47,6 +48,7 @@ import static javax.websocket.CloseReason.CloseCodes.CANNOT_ACCEPT; * @author jiangzeyin * @since 2019/4/24 */ +@Slf4j public abstract class BaseAgentWebSocketHandle { private static final ConcurrentHashMap USER = new ConcurrentHashMap<>(); @@ -54,7 +56,7 @@ public abstract class BaseAgentWebSocketHandle { protected String getParameters(Session session, String name) { Map> requestParameterMap = session.getRequestParameterMap(); Map parameters = session.getPathParameters(); - DefaultSystemLog.getLog().debug("web socket parameters: {} {}", JSONObject.toJSONString(requestParameterMap), parameters); + log.debug("web socket parameters: {} {}", JSONObject.toJSONString(requestParameterMap), parameters); List strings = requestParameterMap.get(name); String value = CollUtil.join(strings, StrUtil.COMMA); if (StrUtil.isEmpty(value)) { @@ -76,7 +78,7 @@ public abstract class BaseAgentWebSocketHandle { try { session.close(new CloseReason(CANNOT_ACCEPT, "授权信息错误")); } catch (Exception e) { - DefaultSystemLog.getLog().error("socket 错误", e); + log.error("socket 错误", e); } return true; } @@ -104,7 +106,7 @@ public abstract class BaseAgentWebSocketHandle { SocketSessionUtil.send(session, "服务端发生异常" + ExceptionUtil.stacktraceToString(thr)); } catch (IOException ignored) { } - DefaultSystemLog.getLog().error(session.getId() + "socket 异常", thr); + log.error(session.getId() + "socket 异常", thr); } protected String getOptUserName(Session session) { @@ -117,7 +119,7 @@ public abstract class BaseAgentWebSocketHandle { try { AgentFileTailWatcher.offline(session); } catch (Exception e) { - DefaultSystemLog.getLog().error("关闭异常", e); + log.error("关闭异常", e); } // top // TopManager.removeMonitor(session); diff --git a/modules/agent/src/main/java/io/jpom/system/init/AutoBackLog.java b/modules/agent/src/main/java/io/jpom/system/init/AutoBackLog.java index c61fa23af..d0c13a970 100644 --- a/modules/agent/src/main/java/io/jpom/system/init/AutoBackLog.java +++ b/modules/agent/src/main/java/io/jpom/system/init/AutoBackLog.java @@ -36,6 +36,7 @@ import io.jpom.model.data.NodeProjectInfoModel; import io.jpom.service.manage.ProjectInfoService; import io.jpom.system.AgentExtConfigBean; import io.jpom.cron.CronUtils; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.util.List; @@ -47,6 +48,7 @@ import java.util.List; * @since 2019/3/17 */ @PreLoadClass +@Slf4j public class AutoBackLog { private static final String ID = "auto_back_log"; @@ -62,7 +64,7 @@ public class AutoBackLog { // 获取cron 表达式 String cron = StrUtil.emptyToDefault(AgentExtConfigBean.getInstance().autoBackConsoleCron, "none"); if ("none".equalsIgnoreCase(cron.trim())) { - //DefaultSystemLog.getLog().info("没有配置自动备份控制台日志表达式"); + //log.info("没有配置自动备份控制台日志表达式"); //return; cron = "0 0/10 * * * ?"; } @@ -85,7 +87,7 @@ public class AutoBackLog { javaCopyItemList.forEach(javaCopyItem -> checkProject(projectInfoModel, javaCopyItem)); }); } catch (Exception e) { - DefaultSystemLog.getLog().error("定时备份日志失败", e); + log.error("定时备份日志失败", e); } }); } diff --git a/modules/agent/src/main/java/io/jpom/system/init/AutoRegSeverNode.java b/modules/agent/src/main/java/io/jpom/system/init/AutoRegSeverNode.java index 7c1e2f715..b85f8759e 100644 --- a/modules/agent/src/main/java/io/jpom/system/init/AutoRegSeverNode.java +++ b/modules/agent/src/main/java/io/jpom/system/init/AutoRegSeverNode.java @@ -47,6 +47,7 @@ import io.jpom.system.AgentConfigBean; import io.jpom.system.AgentExtConfigBean; import io.jpom.system.ConfigBean; import io.jpom.util.JsonFileUtil; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.FileNotFoundException; @@ -64,6 +65,7 @@ import java.util.stream.Collectors; * @since 2019/8/6 */ @PreLoadClass +@Slf4j public class AutoRegSeverNode { /** @@ -94,7 +96,7 @@ public class AutoRegSeverNode { String body1 = execute.body(); JsonMessage jsonMessage = JSON.parseObject(body1, JsonMessage.class); if (jsonMessage.getCode() != HttpStatus.HTTP_OK) { - DefaultSystemLog.getLog().error("获取Server 安装id失败:" + jsonMessage); + log.error("获取Server 安装id失败:" + jsonMessage); return; } String installId = jsonMessage.dataToString(); @@ -115,7 +117,7 @@ public class AutoRegSeverNode { serverRequest.form("type", eqInstall ? "update" : "add"); try (HttpResponse httpResponse = serverRequest.execute()) { String body = httpResponse.body(); - DefaultSystemLog.getLog().info("自动注册Server:" + body); + log.info("自动注册Server:" + body); JsonMessage regJsonMessage = JSON.parseObject(body, JsonMessage.class); if (regJsonMessage.getCode() == HttpStatus.HTTP_OK) { if (serverJson == null) { @@ -129,7 +131,7 @@ public class AutoRegSeverNode { } JsonFileUtil.saveJson(file.getAbsolutePath(), serverJson); } else { - DefaultSystemLog.getLog().error("自动注册插件端失败:{}", body); + log.error("自动注册插件端失败:{}", body); } } } diff --git a/modules/agent/src/main/java/io/jpom/system/init/AutoStartProject.java b/modules/agent/src/main/java/io/jpom/system/init/AutoStartProject.java index 2c590b4f4..f2609abb4 100644 --- a/modules/agent/src/main/java/io/jpom/system/init/AutoStartProject.java +++ b/modules/agent/src/main/java/io/jpom/system/init/AutoStartProject.java @@ -31,6 +31,7 @@ import cn.jiangzeyin.common.spring.SpringUtil; import io.jpom.common.commander.AbstractProjectCommander; import io.jpom.model.data.NodeProjectInfoModel; import io.jpom.service.manage.ProjectInfoService; +import lombok.extern.slf4j.Slf4j; import java.util.List; import java.util.stream.Collectors; @@ -42,6 +43,7 @@ import java.util.stream.Collectors; * @since 2021/12/10 */ @PreLoadClass +@Slf4j public class AutoStartProject { @PreLoadMethod @@ -69,7 +71,7 @@ public class AutoStartProject { } } } catch (Exception e) { - DefaultSystemLog.getLog().warn("自动启动项目失败:{} {}", nodeProjectInfoModel.getId(), e.getMessage()); + log.warn("自动启动项目失败:{} {}", nodeProjectInfoModel.getId(), e.getMessage()); } } }); diff --git a/modules/agent/src/test/java/io/jpom/common/commander/impl/MacOSSystemCommanderTest.java b/modules/agent/src/test/java/io/jpom/common/commander/impl/MacOSSystemCommanderTest.java index e032057aa..f6a73f5fe 100644 --- a/modules/agent/src/test/java/io/jpom/common/commander/impl/MacOSSystemCommanderTest.java +++ b/modules/agent/src/test/java/io/jpom/common/commander/impl/MacOSSystemCommanderTest.java @@ -25,8 +25,10 @@ package io.jpom.common.commander.impl; import cn.hutool.system.OsInfo; import cn.hutool.system.SystemUtil; import cn.jiangzeyin.common.DefaultSystemLog; +import lombok.extern.slf4j.Slf4j; import org.junit.Test; +@Slf4j public class MacOSSystemCommanderTest { private static OsInfo osInfo; @@ -40,9 +42,9 @@ public class MacOSSystemCommanderTest { */ @Test public void testGetAllMonitor() { - DefaultSystemLog.getLog().info("is Mac: {}", osInfo.isMac()); - DefaultSystemLog.getLog().info("is Linux: {}", osInfo.isLinux()); - DefaultSystemLog.getLog().info("is MacOSX: {}", osInfo.isMacOsX()); + log.info("is Mac: {}", osInfo.isMac()); + log.info("is Linux: {}", osInfo.isLinux()); + log.info("is MacOSX: {}", osInfo.isMacOsX()); // Mac OS if (osInfo.isMac() || osInfo.isMacOsX()) { // String result = CommandUtil.execSystemCommand("top -l 1 -n 1"); @@ -60,9 +62,9 @@ public class MacOSSystemCommanderTest { "PID COMMAND %CPU TIME #TH #WQ #PORTS MEM PURG CMPRS PGRP PPID STATE BOOSTS %CPU_ME %CPU_OTHRS UID FAULTS COW MSGSENT MSGRECV SYSBSD SYSMACH CSW PAGEINS IDLEW POWER INSTRS CYCLES USER #MREGS RPRVT VPRVT VSIZE KPRVT KSHRD\n" + "35069 top 0.0 00:00.24 1/1 0 14 3428K 0B 0B 35069 28803 running *0[1] 0.00000 0.00000 0 1603 91 269374 134686 1834 138100 28 0 0 0.0 0 0 root N/A N/A N/A N/A N/A N/A"; - DefaultSystemLog.getLog().info(result); + log.info(result); - DefaultSystemLog.getLog().info("-----------------------------"); + log.info("-----------------------------"); MacOsSystemCommander macOSSystemCommander = new MacOsSystemCommander(); macOSSystemCommander.getAllMonitor(); diff --git a/modules/common/src/main/java/io/jpom/JpomApplication.java b/modules/common/src/main/java/io/jpom/JpomApplication.java index 6c800485d..370d6cc6d 100644 --- a/modules/common/src/main/java/io/jpom/JpomApplication.java +++ b/modules/common/src/main/java/io/jpom/JpomApplication.java @@ -43,6 +43,7 @@ import io.jpom.common.JpomManifest; import io.jpom.common.Type; import io.jpom.plugin.PluginFactory; import io.jpom.util.CommandUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.core.env.Environment; import org.springframework.http.converter.StringHttpMessageConverter; @@ -60,6 +61,7 @@ import java.util.concurrent.TimeUnit; * @author jiangzeyin * @since 2019/4/16 */ +@Slf4j public class JpomApplication extends ApplicationBuilder { /** @@ -202,7 +204,7 @@ public class JpomApplication extends ApplicationBuilder { CommandUtil.asyncExeLocalCommand(scriptFile.getParentFile(), command); } } catch (Exception e) { - DefaultSystemLog.getLog().error("重启自身异常", e); + log.error("重启自身异常", e); } }); } diff --git a/modules/common/src/main/java/io/jpom/common/JpomApplicationEvent.java b/modules/common/src/main/java/io/jpom/common/JpomApplicationEvent.java index 8cdae4c27..ecad9f02b 100644 --- a/modules/common/src/main/java/io/jpom/common/JpomApplicationEvent.java +++ b/modules/common/src/main/java/io/jpom/common/JpomApplicationEvent.java @@ -38,6 +38,7 @@ import io.jpom.JpomApplication; import io.jpom.system.ConfigBean; import io.jpom.system.ExtConfigBean; import io.jpom.util.JsonFileUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.ApplicationEvent; import org.springframework.context.event.ContextClosedEvent; @@ -57,6 +58,7 @@ import java.util.List; * @author jiangzeyin * @since 2019/4/7 */ +@Slf4j public class JpomApplicationEvent implements ApplicationEventClient { private FileLock lock; private FileOutputStream fileOutputStream; @@ -78,7 +80,7 @@ public class JpomApplicationEvent implements ApplicationEventClient { try { this.lockFile(jpomManifest.getPid()); } catch (IOException e) { - DefaultSystemLog.getLog().error("lockFile", e); + log.error("lockFile", e); } // 写入Jpom 信息 、 写入全局信息 File appJpomFile = instance.getApplicationJpomInfo(JpomApplication.getAppType()); @@ -133,7 +135,7 @@ public class JpomApplicationEvent implements ApplicationEventClient { lock = fileChannel.lock(); break; } catch (OverlappingFileLockException | IOException e) { - DefaultSystemLog.getLog().warn("获取进程文件锁失败:" + e.getMessage()); + log.warn("获取进程文件锁失败:" + e.getMessage()); } ThreadUtil.sleep(100); } @@ -151,7 +153,7 @@ public class JpomApplicationEvent implements ApplicationEventClient { FileUtil.mkdir(file); file = FileUtil.createTempFile("jpom", ".temp", file, true); } catch (Exception e) { - DefaultSystemLog.getLog().error(StrUtil.format("Jpom Failed to create data directory, directory location:{}," + + log.error(StrUtil.format("Jpom Failed to create data directory, directory location:{}," + "Please check whether the current user has permission to this directory or modify the configuration file:{} jpom.path in is the path where the directory can be created", path, extConfigPath), e); System.exit(-1); } @@ -178,7 +180,7 @@ public class JpomApplicationEvent implements ApplicationEventClient { File oldJars = JpomManifest.getOldJarsPath(); FileUtil.mkdir(oldJars); FileUtil.move(beforeJarFile, oldJars, true); - DefaultSystemLog.getLog().info("备份旧程序包:" + beforeJar); + log.info("备份旧程序包:" + beforeJar); } } } diff --git a/modules/common/src/main/java/io/jpom/common/JpomManifest.java b/modules/common/src/main/java/io/jpom/common/JpomManifest.java index ce5730999..1f04c2932 100644 --- a/modules/common/src/main/java/io/jpom/common/JpomManifest.java +++ b/modules/common/src/main/java/io/jpom/common/JpomManifest.java @@ -47,6 +47,7 @@ import io.jpom.system.ExtConfigBean; import io.jpom.system.JpomRuntimeException; import io.jpom.util.CommandUtil; import io.jpom.util.JsonFileUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.Assert; import java.io.File; @@ -71,6 +72,7 @@ import java.util.zip.ZipFile; * @author jiangzeyin * @since 2019/4/7 */ +@Slf4j public class JpomManifest { private volatile static JpomManifest JPOM_MANIFEST; @@ -384,7 +386,7 @@ public class JpomManifest { } } } catch (Exception e) { - DefaultSystemLog.getLog().error("解析jar", e); + log.error("解析jar", e); return new JsonMessage<>(500, " 解析错误:" + e.getMessage()); } return new JsonMessage<>(200, "", jarVersion); diff --git a/modules/common/src/main/java/io/jpom/common/RemoteVersion.java b/modules/common/src/main/java/io/jpom/common/RemoteVersion.java index 8e4c3ffb6..fd7c42aaa 100644 --- a/modules/common/src/main/java/io/jpom/common/RemoteVersion.java +++ b/modules/common/src/main/java/io/jpom/common/RemoteVersion.java @@ -141,7 +141,7 @@ public class RemoteVersion extends BaseJsonModel { RemoteVersion.cacheLoadTime(remoteVersion); return remoteVersion; } catch (Exception e) { - DefaultSystemLog.getLog().warn("获取远程版本信息失败:{} {}", e.getMessage(), body); + log.warn("获取远程版本信息失败:{} {}", e.getMessage(), body); return null; } } @@ -172,7 +172,7 @@ public class RemoteVersion extends BaseJsonModel { } return loadTransitUrl(jumpUrl); } catch (Exception e) { - DefaultSystemLog.getLog().warn("获取远程版本信息失败:{} {}", e.getMessage(), body); + log.warn("获取远程版本信息失败:{} {}", e.getMessage(), body); return null; } } @@ -231,7 +231,7 @@ public class RemoteVersion extends BaseJsonModel { } remoteVersion = JSONObject.parseObject(fileStr, RemoteVersion.class); } catch (Exception e) { - DefaultSystemLog.getLog().warn("解析远程版本信息失败:{} {}", e.getMessage(), fileStr); + log.warn("解析远程版本信息失败:{} {}", e.getMessage(), fileStr); } // 判断上次获取时间 Long lastTime = remoteVersion == null ? 0 : remoteVersion.getLastTime(); diff --git a/modules/common/src/main/java/io/jpom/controller/BaseMyErrorController.java b/modules/common/src/main/java/io/jpom/controller/BaseMyErrorController.java index 2a90b3ace..75d91faef 100644 --- a/modules/common/src/main/java/io/jpom/controller/BaseMyErrorController.java +++ b/modules/common/src/main/java/io/jpom/controller/BaseMyErrorController.java @@ -24,6 +24,7 @@ package io.jpom.controller; import cn.jiangzeyin.common.DefaultSystemLog; import cn.jiangzeyin.common.JsonMessage; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.http.HttpStatus; @@ -42,6 +43,7 @@ import java.util.Map; * @since 2021/3/17 * @see org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController */ +@Slf4j public abstract class BaseMyErrorController extends AbstractErrorController { public static final String FILE_MAX_SIZE_MSG = "上传文件太大了,请重新选择一个较小的文件上传吧"; @@ -58,7 +60,7 @@ public abstract class BaseMyErrorController extends AbstractErrorController { } Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); String requestUri = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); - DefaultSystemLog.getLog().error("发生异常:" + statusCode + " " + requestUri); + log.error("发生异常:" + statusCode + " " + requestUri); // 判断异常信息 Object attribute = request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); Map body = new HashMap<>(5); diff --git a/modules/common/src/main/java/io/jpom/cron/CronUtils.java b/modules/common/src/main/java/io/jpom/cron/CronUtils.java index b9176184a..17f2ba825 100644 --- a/modules/common/src/main/java/io/jpom/cron/CronUtils.java +++ b/modules/common/src/main/java/io/jpom/cron/CronUtils.java @@ -32,6 +32,7 @@ import cn.hutool.cron.task.Task; import cn.jiangzeyin.common.DefaultSystemLog; import com.alibaba.fastjson.JSONObject; import io.jpom.system.ExtConfigBean; +import lombok.extern.slf4j.Slf4j; import java.util.List; import java.util.Map; @@ -43,143 +44,144 @@ import java.util.stream.Collectors; * @author bwcx_jzy * @since 2019/7/12 **/ +@Slf4j public class CronUtils { - private static final Map TASK_STAT = new ConcurrentHashMap<>(50); + private static final Map TASK_STAT = new ConcurrentHashMap<>(50); - /** - * 任务统计 - */ - private static class TaskStat { - /** - * 执行次数 - */ - private int executeCount; - /** - * 失败次数 - */ - private int failedCount; - /** - * 成功次数 - */ - private int succeedCount; - /** - * 最后执行时间 - */ - private Long lastExecuteTime; - } + /** + * 任务统计 + */ + private static class TaskStat { + /** + * 执行次数 + */ + private int executeCount; + /** + * 失败次数 + */ + private int failedCount; + /** + * 成功次数 + */ + private int succeedCount; + /** + * 最后执行时间 + */ + private Long lastExecuteTime; + } - /** - * 开始 - */ - public static void start() { - boolean matchSecond = ExtConfigBean.getInstance().getTimerMatchSecond(); - // 开启秒级 - CronUtil.setMatchSecond(matchSecond); - // - Scheduler scheduler = CronUtil.getScheduler(); - // - boolean started = scheduler.isStarted(); - if (started) { - return; - } - synchronized (CronUtils.class) { - started = scheduler.isStarted(); - if (started) { - return; - } - CronUtil.start(); - scheduler.addListener(new TaskListener() { - @Override - public void onStart(TaskExecutor executor) { - TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat()); - taskStat.lastExecuteTime = SystemClock.now(); - taskStat.executeCount++; - } + /** + * 开始 + */ + public static void start() { + boolean matchSecond = ExtConfigBean.getInstance().getTimerMatchSecond(); + // 开启秒级 + CronUtil.setMatchSecond(matchSecond); + // + Scheduler scheduler = CronUtil.getScheduler(); + // + boolean started = scheduler.isStarted(); + if (started) { + return; + } + synchronized (CronUtils.class) { + started = scheduler.isStarted(); + if (started) { + return; + } + CronUtil.start(); + scheduler.addListener(new TaskListener() { + @Override + public void onStart(TaskExecutor executor) { + TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat()); + taskStat.lastExecuteTime = SystemClock.now(); + taskStat.executeCount++; + } - @Override - public void onSucceeded(TaskExecutor executor) { - TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat()); - taskStat.succeedCount++; - } + @Override + public void onSucceeded(TaskExecutor executor) { + TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat()); + taskStat.succeedCount++; + } - @Override - public void onFailed(TaskExecutor executor, Throwable exception) { - TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat()); - taskStat.failedCount++; - DefaultSystemLog.getLog().error("定时任务异常", exception); - } - }); - } - } + @Override + public void onFailed(TaskExecutor executor, Throwable exception) { + TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat()); + taskStat.failedCount++; + log.error("定时任务异常", exception); + } + }); + } + } - /** - * 获取任务列表 - * - * @return list - */ - public static List list() { - Scheduler scheduler = CronUtil.getScheduler(); - TaskTable taskTable = scheduler.getTaskTable(); - List ids = taskTable.getIds(); - return ids.stream().map(s -> { - TaskStat taskStat = TASK_STAT.get(s); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("taskId", s); - jsonObject.put("cron", scheduler.getPattern(s).toString()); - if (taskStat != null) { - jsonObject.put("executeCount", taskStat.executeCount); - jsonObject.put("failedCount", taskStat.failedCount); - jsonObject.put("succeedCount", taskStat.succeedCount); - jsonObject.put("lastExecuteTime", taskStat.lastExecuteTime); - } - return jsonObject; - }).collect(Collectors.toList()); - } + /** + * 获取任务列表 + * + * @return list + */ + public static List list() { + Scheduler scheduler = CronUtil.getScheduler(); + TaskTable taskTable = scheduler.getTaskTable(); + List ids = taskTable.getIds(); + return ids.stream().map(s -> { + TaskStat taskStat = TASK_STAT.get(s); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", s); + jsonObject.put("cron", scheduler.getPattern(s).toString()); + if (taskStat != null) { + jsonObject.put("executeCount", taskStat.executeCount); + jsonObject.put("failedCount", taskStat.failedCount); + jsonObject.put("succeedCount", taskStat.succeedCount); + jsonObject.put("lastExecuteTime", taskStat.lastExecuteTime); + } + return jsonObject; + }).collect(Collectors.toList()); + } - /** - * 添加任务 已经存在则不添加 - * - * @param id 任务ID - * @param cron 表达式 - * @param supplier 创建任务回调 - */ - public static void add(String id, String cron, Supplier supplier) { - Scheduler scheduler = CronUtil.getScheduler(); - Task task = scheduler.getTask(id); - if (task != null) { - return; - } - scheduler.schedule(id, cron, supplier.get()); - // - CronUtils.start(); - } + /** + * 添加任务 已经存在则不添加 + * + * @param id 任务ID + * @param cron 表达式 + * @param supplier 创建任务回调 + */ + public static void add(String id, String cron, Supplier supplier) { + Scheduler scheduler = CronUtil.getScheduler(); + Task task = scheduler.getTask(id); + if (task != null) { + return; + } + scheduler.schedule(id, cron, supplier.get()); + // + CronUtils.start(); + } - /** - * 添加任务、自动去重 - * - * @param id 任务ID - * @param cron 表达式 - * @param task 任务作业 - */ - public static void upsert(String id, String cron, Task task) { - Scheduler scheduler = CronUtil.getScheduler(); - Task schedulerTask = scheduler.getTask(id); - if (schedulerTask != null) { - CronUtil.remove(id); - } - // 创建任务 - CronUtil.schedule(id, cron, task); - // - CronUtils.start(); - } + /** + * 添加任务、自动去重 + * + * @param id 任务ID + * @param cron 表达式 + * @param task 任务作业 + */ + public static void upsert(String id, String cron, Task task) { + Scheduler scheduler = CronUtil.getScheduler(); + Task schedulerTask = scheduler.getTask(id); + if (schedulerTask != null) { + CronUtil.remove(id); + } + // 创建任务 + CronUtil.schedule(id, cron, task); + // + CronUtils.start(); + } - /** - * 停止定时任务 - * - * @param id ID - */ - public static void remove(String id) { - CronUtil.remove(id); - } + /** + * 停止定时任务 + * + * @param id ID + */ + public static void remove(String id) { + CronUtil.remove(id); + } } diff --git a/modules/common/src/main/java/io/jpom/model/BaseEnum.java b/modules/common/src/main/java/io/jpom/model/BaseEnum.java index 61ce9d65e..408dc36f5 100644 --- a/modules/common/src/main/java/io/jpom/model/BaseEnum.java +++ b/modules/common/src/main/java/io/jpom/model/BaseEnum.java @@ -22,9 +22,11 @@ */ package io.jpom.model; +import cn.hutool.log.StaticLog; import cn.jiangzeyin.common.DefaultSystemLog; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -78,7 +80,7 @@ public interface BaseEnum { map1.put(item.getCode(), item); } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - DefaultSystemLog.getLog().error("enum error", e); + StaticLog.error("enum error", e); return null; } return map1; @@ -185,7 +187,7 @@ public interface BaseEnum { jsonArray.add(jsonObject); } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - DefaultSystemLog.getLog().error("enum error", e); + StaticLog.error("enum error", e); return null; } return jsonArray; diff --git a/modules/common/src/main/java/io/jpom/model/data/AgentWhitelist.java b/modules/common/src/main/java/io/jpom/model/data/AgentWhitelist.java index 3211d2518..9aad5c7ba 100644 --- a/modules/common/src/main/java/io/jpom/model/data/AgentWhitelist.java +++ b/modules/common/src/main/java/io/jpom/model/data/AgentWhitelist.java @@ -33,6 +33,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.common.BaseJpomController; import io.jpom.model.BaseJsonModel; import io.jpom.system.ExtConfigBean; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.Assert; import java.io.File; @@ -45,6 +46,7 @@ import java.util.*; * @author jiangzeyin * @since 2019/4/16 */ +@Slf4j public class AgentWhitelist extends BaseJsonModel { /** * 项目目录白名单、日志文件白名单 @@ -148,7 +150,7 @@ public class AgentWhitelist extends BaseJsonModel { try { return CollUtil.join(jsonArray, StrUtil.CRLF); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); } return ""; } diff --git a/modules/common/src/main/java/io/jpom/plugin/PluginFactory.java b/modules/common/src/main/java/io/jpom/plugin/PluginFactory.java index f0ea9db73..7770ad149 100644 --- a/modules/common/src/main/java/io/jpom/plugin/PluginFactory.java +++ b/modules/common/src/main/java/io/jpom/plugin/PluginFactory.java @@ -138,7 +138,7 @@ public class PluginFactory implements ApplicationContextInitializer new PluginItemWrap((Class) aClass)) .filter(pluginItemWrap -> { if (StrUtil.isEmpty(pluginItemWrap.getName())) { - DefaultSystemLog.getLog().warn("plugin config name error:{}", pluginItemWrap.getClassName()); + log.warn("plugin config name error:{}", pluginItemWrap.getClassName()); return false; } return true; diff --git a/modules/common/src/main/java/io/jpom/system/WebAopLog.java b/modules/common/src/main/java/io/jpom/system/WebAopLog.java index 60af93aa5..72f8701a4 100644 --- a/modules/common/src/main/java/io/jpom/system/WebAopLog.java +++ b/modules/common/src/main/java/io/jpom/system/WebAopLog.java @@ -31,6 +31,7 @@ import cn.jiangzeyin.common.interceptor.BaseCallbackController; import io.jpom.JpomApplication; import io.jpom.common.JpomManifest; import io.jpom.util.StringUtil; +import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @@ -46,6 +47,7 @@ import java.io.File; */ @Aspect @Component +@Slf4j public class WebAopLog extends PropertyDefinerBase { private static volatile AopLogInterface aopLogInterface; @@ -80,7 +82,7 @@ public class WebAopLog extends PropertyDefinerBase { } } if (consoleLogReqResponse && logResult != null) { - DefaultSystemLog.getLog().info(BaseCallbackController.getRequestAttributes().getRequest().getRequestURI() + " :" + logResult); + log.info(BaseCallbackController.getRequestAttributes().getRequest().getRequestURI() + " :" + logResult); } return proceed; } diff --git a/modules/common/src/main/java/io/jpom/system/init/CheckPath.java b/modules/common/src/main/java/io/jpom/system/init/CheckPath.java index 2a0472af4..dc5b00a57 100644 --- a/modules/common/src/main/java/io/jpom/system/init/CheckPath.java +++ b/modules/common/src/main/java/io/jpom/system/init/CheckPath.java @@ -34,6 +34,7 @@ import io.jpom.common.JpomManifest; import io.jpom.system.ConfigBean; import io.jpom.system.ExtConfigBean; import io.jpom.util.JvmUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpMethod; import javax.servlet.http.HttpServletRequest; @@ -50,84 +51,85 @@ import java.util.Map; * @since 2019/3/26 */ @PreLoadClass(value = Integer.MIN_VALUE) +@Slf4j public class CheckPath { - /** - * 判断是否重复运行 - */ - @PreLoadMethod(2) - private static void checkDuplicateRun() { - try { - Class appClass = JpomApplication.getAppClass(); - String pid = String.valueOf(JpomManifest.getInstance().getPid()); - Integer mainClassPid = JvmUtil.findMainClassPid(appClass.getName()); - if (mainClassPid == null || pid.equals(ObjectUtil.toString(mainClassPid))) { - return; - } - DefaultSystemLog.getLog().warn("The Jpom program recommends that only one corresponding program be run on a machine:" + JpomApplication.getAppType() + " pid:" + mainClassPid); - } catch (Exception e) { - DefaultSystemLog.getLog().error("检查异常", e); - } - } + /** + * 判断是否重复运行 + */ + @PreLoadMethod(2) + private static void checkDuplicateRun() { + try { + Class appClass = JpomApplication.getAppClass(); + String pid = String.valueOf(JpomManifest.getInstance().getPid()); + Integer mainClassPid = JvmUtil.findMainClassPid(appClass.getName()); + if (mainClassPid == null || pid.equals(ObjectUtil.toString(mainClassPid))) { + return; + } + log.warn("The Jpom program recommends that only one corresponding program be run on a machine:" + JpomApplication.getAppType() + " pid:" + mainClassPid); + } catch (Exception e) { + log.error("检查异常", e); + } + } - @PreLoadMethod(3) - private static void reqXssLog() { - if (!ExtConfigBean.getInstance().isConsoleLogReqXss()) { - // 不在控制台记录请求日志信息 - DefaultSystemLog.setLogCallback(new DefaultSystemLog.LogCallback() { - @Override - public void log(DefaultSystemLog.LogType type, Object... log) { - // - if (type == DefaultSystemLog.LogType.REQUEST_ERROR) { - DefaultSystemLog.getLog().info(Arrays.toString(log)); - } - } + @PreLoadMethod(3) + private static void reqXssLog() { + if (!ExtConfigBean.getInstance().isConsoleLogReqXss()) { + // 不在控制台记录请求日志信息 + DefaultSystemLog.setLogCallback(new DefaultSystemLog.LogCallback() { + @Override + public void log(DefaultSystemLog.LogType type, Object... log) { + // + if (type == DefaultSystemLog.LogType.REQUEST_ERROR) { + CheckPath.log.info(Arrays.toString(log)); + } + } - @Override - public void logStart(HttpServletRequest request, String id, String url, HttpMethod httpMethod, String ip, Map parameters, Map header) { + @Override + public void logStart(HttpServletRequest request, String id, String url, HttpMethod httpMethod, String ip, Map parameters, Map header) { - } + } - @Override - public void logError(String id, int status) { + @Override + public void logError(String id, int status) { - } + } - @Override - public void logTimeOut(String id, long time) { + @Override + public void logTimeOut(String id, long time) { - } - }); - } - } + } + }); + } + } - @PreLoadMethod(4) - private static void clearTemp() { - File file = ConfigBean.getInstance().getTempPath(); - /** - * @author Hotstrip - * use Hutool's FileUtil.del method just put file as param not file's path - * or else, may be return Accessdenied exception - */ - try { - FileUtil.del(file); - } catch (Exception e) { - // Try again jzy 2021-07-31 - DefaultSystemLog.getLog().warn("Attempt to delete temporary folder failed, try to handle read-only permission:{}", e.getMessage()); - List files = FileUtil.loopFiles(file); - long count = files.stream().map(file12 -> file12.setWritable(true)).filter(aBoolean -> aBoolean).count(); - DefaultSystemLog.getLog().warn("Cumulative number of files in temporary folder: {}, number of successful processing:{}", CollUtil.size(files), count); - try { - FileUtil.del(file.toPath()); - } catch (Exception e1) { - e1.addSuppressed(e); - boolean causedBy = ExceptionUtil.isCausedBy(e1, AccessDeniedException.class); - if (causedBy) { - DefaultSystemLog.getLog().error("清除临时文件失败,请手动清理:" + FileUtil.getAbsolutePath(file), e); - return; - } - DefaultSystemLog.getLog().error("清除临时文件失败,请检查目录:" + FileUtil.getAbsolutePath(file), e); - } - } - } + @PreLoadMethod(4) + private static void clearTemp() { + File file = ConfigBean.getInstance().getTempPath(); + /** + * @author Hotstrip + * use Hutool's FileUtil.del method just put file as param not file's path + * or else, may be return Accessdenied exception + */ + try { + FileUtil.del(file); + } catch (Exception e) { + // Try again jzy 2021-07-31 + log.warn("Attempt to delete temporary folder failed, try to handle read-only permission:{}", e.getMessage()); + List files = FileUtil.loopFiles(file); + long count = files.stream().map(file12 -> file12.setWritable(true)).filter(aBoolean -> aBoolean).count(); + log.warn("Cumulative number of files in temporary folder: {}, number of successful processing:{}", CollUtil.size(files), count); + try { + FileUtil.del(file.toPath()); + } catch (Exception e1) { + e1.addSuppressed(e); + boolean causedBy = ExceptionUtil.isCausedBy(e1, AccessDeniedException.class); + if (causedBy) { + log.error("清除临时文件失败,请手动清理:" + FileUtil.getAbsolutePath(file), e); + return; + } + log.error("清除临时文件失败,请检查目录:" + FileUtil.getAbsolutePath(file), e); + } + } + } } diff --git a/modules/common/src/main/java/io/jpom/system/init/ConsoleStartSuccess.java b/modules/common/src/main/java/io/jpom/system/init/ConsoleStartSuccess.java index e88e66e85..f510d4753 100644 --- a/modules/common/src/main/java/io/jpom/system/init/ConsoleStartSuccess.java +++ b/modules/common/src/main/java/io/jpom/system/init/ConsoleStartSuccess.java @@ -35,6 +35,7 @@ import io.jpom.common.Type; import io.jpom.cron.IAsyncLoad; import io.jpom.cron.ICron; import io.jpom.system.ConfigBean; +import lombok.extern.slf4j.Slf4j; import java.util.Map; @@ -43,6 +44,7 @@ import java.util.Map; * @since Created Time 2021/8/2 */ @PreLoadClass(value = Integer.MAX_VALUE) +@Slf4j public class ConsoleStartSuccess { @@ -55,7 +57,7 @@ public class ConsoleStartSuccess { cronMap.forEach((name, iCron) -> { int startCron = iCron.startCron(); if (startCron > 0) { - DefaultSystemLog.getLog().debug("{} scheduling has been started:{}", name, startCron); + log.debug("{} scheduling has been started:{}", name, startCron); } }); Map asyncLoadMap = SpringUtil.getApplicationContext().getBeansOfType(IAsyncLoad.class); diff --git a/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java b/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java index 677f29572..f12598213 100644 --- a/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java +++ b/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java @@ -31,6 +31,7 @@ import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.plugin.PluginFactory; import io.jpom.system.ExtConfigBean; import io.jpom.system.JpomRuntimeException; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.WebSocketSession; import javax.websocket.Session; @@ -48,6 +49,7 @@ import java.util.Set; * @author bwcx_jzy * @since 2019/7/21 */ +@Slf4j public abstract class BaseFileTailWatcher { protected File logFile; @@ -79,7 +81,7 @@ public abstract class BaseFileTailWatcher { String charsetName = (String) PluginFactory.getPlugin("charset-detector").execute(logFile); detSet = StrUtil.isEmpty(charsetName) ? CharsetUtil.CHARSET_UTF_8 : CharsetUtil.charset(charsetName); } catch (Exception e) { - DefaultSystemLog.getLog().warn("自动识别文件编码格式错误:{}", e.getMessage()); + log.warn("自动识别文件编码格式错误:{}", e.getMessage()); detSet = CharsetUtil.CHARSET_UTF_8; } detSet = (detSet == StandardCharsets.US_ASCII) ? CharsetUtil.CHARSET_UTF_8 : detSet; @@ -112,7 +114,7 @@ public abstract class BaseFileTailWatcher { try { this.send(socketSession, msg); } catch (Exception e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); iterator.remove(); } } diff --git a/modules/common/src/main/java/io/jpom/util/CommandUtil.java b/modules/common/src/main/java/io/jpom/util/CommandUtil.java index 9780fe902..8c293010b 100644 --- a/modules/common/src/main/java/io/jpom/util/CommandUtil.java +++ b/modules/common/src/main/java/io/jpom/util/CommandUtil.java @@ -30,6 +30,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.system.SystemUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.system.ExtConfigBean; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.IOException; @@ -46,6 +47,7 @@ import java.util.concurrent.ConcurrentHashMap; * @author jiangzeyin * @since 2019/4/15 */ +@Slf4j public class CommandUtil { /** * 系统命令 @@ -149,7 +151,7 @@ public class CommandUtil { String[] cmd = commands.toArray(new String[]{}); result = exec(cmd, file); } catch (Exception e) { - DefaultSystemLog.getLog().error("执行命令异常", e); + log.error("执行命令异常", e); result += e.getMessage(); } return result; @@ -165,20 +167,20 @@ public class CommandUtil { private static String exec(String[] cmd, File file) throws IOException { Process process = new ProcessBuilder(cmd).directory(file).redirectErrorStream(true).start(); Charset charset; - boolean log; + boolean isLog; try { charset = ExtConfigBean.getInstance().getConsoleLogCharset(); - log = true; + isLog = true; } catch (Exception e) { // 直接执行,使用默认编码格式 charset = CharsetUtil.systemCharset(); // 不记录日志 - log = false; + isLog = false; } charset = ObjectUtil.defaultIfNull(charset, CharsetUtil.defaultCharset()); String result = RuntimeUtil.getResult(process, charset); - if (log) { - DefaultSystemLog.getLog().debug("exec {} {} {}", charset.name(), Arrays.toString(cmd), result); + if (isLog) { + log.debug("exec {} {} {}", charset.name(), Arrays.toString(cmd), result); } return result; } @@ -194,7 +196,7 @@ public class CommandUtil { String newCommand = StrUtil.replace(command, StrUtil.CRLF, StrUtil.SPACE); newCommand = StrUtil.replace(newCommand, StrUtil.LF, StrUtil.SPACE); // - DefaultSystemLog.getLog().debug(newCommand); + log.debug(newCommand); List commands = getCommand(); commands.add(newCommand); ProcessBuilder pb = new ProcessBuilder(commands); diff --git a/modules/common/src/main/java/io/jpom/util/LogRecorder.java b/modules/common/src/main/java/io/jpom/util/LogRecorder.java index 3513507d4..e0af5bab5 100644 --- a/modules/common/src/main/java/io/jpom/util/LogRecorder.java +++ b/modules/common/src/main/java/io/jpom/util/LogRecorder.java @@ -30,6 +30,7 @@ import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; import lombok.Builder; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.PrintWriter; @@ -42,6 +43,7 @@ import java.nio.charset.Charset; * @since 2022/1/26 */ @Builder +@Slf4j public class LogRecorder implements AutoCloseable { /** * 文件 @@ -77,7 +79,7 @@ public class LogRecorder implements AutoCloseable { * @param throwable 堆栈信息 */ public void error(String title, Throwable throwable) { - DefaultSystemLog.getLog().error(title, throwable); + log.error(title, throwable); FileUtil.appendLines(CollectionUtil.toList(title), this.getFile(), this.getCharset()); String s = ExceptionUtil.stacktraceToString(throwable); FileUtil.appendLines(CollectionUtil.toList(s), this.getFile(), this.getCharset()); diff --git a/modules/common/src/main/java/io/jpom/util/SocketSessionUtil.java b/modules/common/src/main/java/io/jpom/util/SocketSessionUtil.java index 0aff5fe6a..01e5bc3b5 100644 --- a/modules/common/src/main/java/io/jpom/util/SocketSessionUtil.java +++ b/modules/common/src/main/java/io/jpom/util/SocketSessionUtil.java @@ -25,6 +25,7 @@ package io.jpom.util; import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -37,6 +38,7 @@ import java.io.IOException; * @author jiangzeyin * @since 2018/9/29 */ +@Slf4j public class SocketSessionUtil { /** * 锁 @@ -76,7 +78,7 @@ public class SocketSessionUtil { exception = null; break; } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败:" + tryCount, e); + log.error("发送消息失败:" + tryCount, e); exception = e; } } while (tryCount <= ERROR_TRY_COUNT); @@ -110,7 +112,7 @@ public class SocketSessionUtil { exception = null; break; } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败:" + tryCount, e); + log.error("发送消息失败:" + tryCount, e); exception = e; } } while (tryCount <= ERROR_TRY_COUNT); diff --git a/modules/common/src/test/java/cn/VersionUtils.java b/modules/common/src/test/java/cn/VersionUtils.java index 18fc638c3..818acb85c 100644 --- a/modules/common/src/test/java/cn/VersionUtils.java +++ b/modules/common/src/test/java/cn/VersionUtils.java @@ -25,6 +25,7 @@ package cn; import cn.hutool.core.io.file.FileNameUtil; import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; +import lombok.extern.slf4j.Slf4j; import java.security.CodeSource; @@ -34,68 +35,69 @@ import java.security.CodeSource; * * @author Hotstrip */ +@Slf4j public final class VersionUtils { - private static final String VERSION = getVersion(VersionUtils.class, "1.0.0"); + private static final String VERSION = getVersion(VersionUtils.class, "1.0.0"); - private VersionUtils() { - } + private VersionUtils() { + } - /** - * Gets version. - * - * @return the version - */ - public static String getVersion() { - return VERSION; - } + /** + * Gets version. + * + * @return the version + */ + public static String getVersion() { + return VERSION; + } - /** - * Gets version. - * - * @param cls the cls - * @param defaultVersion the default version - * @return the version - */ - public static String getVersion(final Class cls, final String defaultVersion) { - // find version info from MANIFEST.MF first - String version = cls.getPackage().getImplementationVersion(); - if (StrUtil.isEmpty(version)) { - version = cls.getPackage().getSpecificationVersion(); - } - if (!StrUtil.isEmpty(version)) { - return version; - } - // guess version fro jar file name if nothing's found from MANIFEST.MF - CodeSource codeSource = cls.getProtectionDomain().getCodeSource(); + /** + * Gets version. + * + * @param cls the cls + * @param defaultVersion the default version + * @return the version + */ + public static String getVersion(final Class cls, final String defaultVersion) { + // find version info from MANIFEST.MF first + String version = cls.getPackage().getImplementationVersion(); + if (StrUtil.isEmpty(version)) { + version = cls.getPackage().getSpecificationVersion(); + } + if (!StrUtil.isEmpty(version)) { + return version; + } + // guess version fro jar file name if nothing's found from MANIFEST.MF + CodeSource codeSource = cls.getProtectionDomain().getCodeSource(); - if (codeSource == null) { - DefaultSystemLog.getLog().warn("No codeSource for class {} when getVersion, use default version {}", cls.getName(), defaultVersion); - return defaultVersion; - } - String file = codeSource.getLocation().getFile(); - if (file != null && file.endsWith(FileNameUtil.EXT_JAR)) { - file = file.substring(0, file.length() - 4); - int i = file.lastIndexOf('/'); - if (i >= 0) { - file = file.substring(i + 1); - } - i = file.indexOf("-"); - if (i >= 0) { - file = file.substring(i + 1); - } - while (file.length() > 0 && !Character.isDigit(file.charAt(0))) { - i = file.indexOf("-"); - if (i < 0) { - break; - } - file = file.substring(i + 1); - } - version = file; - } - // return default version if no version info is found - return StrUtil.isEmpty(version) ? defaultVersion : version; - } + if (codeSource == null) { + log.warn("No codeSource for class {} when getVersion, use default version {}", cls.getName(), defaultVersion); + return defaultVersion; + } + String file = codeSource.getLocation().getFile(); + if (file != null && file.endsWith(FileNameUtil.EXT_JAR)) { + file = file.substring(0, file.length() - 4); + int i = file.lastIndexOf('/'); + if (i >= 0) { + file = file.substring(i + 1); + } + i = file.indexOf("-"); + if (i >= 0) { + file = file.substring(i + 1); + } + while (file.length() > 0 && !Character.isDigit(file.charAt(0))) { + i = file.indexOf("-"); + if (i < 0) { + break; + } + file = file.substring(i + 1); + } + version = file; + } + // return default version if no version info is found + return StrUtil.isEmpty(version) ? defaultVersion : version; + } } diff --git a/modules/server/src/main/java/io/jpom/build/BuildExecuteService.java b/modules/server/src/main/java/io/jpom/build/BuildExecuteService.java index 14497c0fd..c759d3998 100644 --- a/modules/server/src/main/java/io/jpom/build/BuildExecuteService.java +++ b/modules/server/src/main/java/io/jpom/build/BuildExecuteService.java @@ -63,6 +63,7 @@ import io.jpom.util.FileUtils; import io.jpom.util.LogRecorder; import io.jpom.util.StringUtil; import lombok.Builder; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.AntPathMatcher; import org.springframework.util.Assert; @@ -86,6 +87,7 @@ import java.util.stream.Collectors; * @since 2022/1/26 */ @Service +@Slf4j public class BuildExecuteService { /** @@ -807,7 +809,7 @@ public class BuildExecuteService { try { plugin.execute(webhook, map); } catch (Exception e) { - DefaultSystemLog.getLog().error("WebHooks 调用错误", e); + log.error("WebHooks 调用错误", e); } }); diff --git a/modules/server/src/main/java/io/jpom/common/forward/NodeForward.java b/modules/server/src/main/java/io/jpom/common/forward/NodeForward.java index 4d2a72bb2..962ebf89d 100644 --- a/modules/server/src/main/java/io/jpom/common/forward/NodeForward.java +++ b/modules/server/src/main/java/io/jpom/common/forward/NodeForward.java @@ -46,6 +46,7 @@ import io.jpom.system.AgentException; import io.jpom.system.AuthorizeException; import io.jpom.system.ConfigBean; import io.jpom.system.ServerExtConfigBean; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -63,6 +64,7 @@ import java.util.Set; * @author jiangzeyin * @since 2019/4/16 */ +@Slf4j public class NodeForward { /** @@ -216,7 +218,7 @@ public class NodeForward { private static AgentException responseException(Exception exception, NodeModel nodeModel) { String message = exception.getMessage(); Throwable cause = exception.getCause(); - DefaultSystemLog.getLog().error("node [{}] connect failed...message: [{}]", nodeModel.getName(), message); + log.error("node [{}] connect failed...message: [{}]", nodeModel.getName(), message); if (exception instanceof IORuntimeException) { if (cause instanceof java.net.ConnectException || cause instanceof java.net.SocketTimeoutException) { return new AgentException(nodeModel.getName() + "节点网络连接异常或超时,请优先检查插件端运行状态再检查 IP 地址、" + @@ -302,7 +304,7 @@ public class NodeForward { try { httpRequest.form(s, multipartFile.getBytes(), multipartFile.getOriginalFilename()); } catch (IOException e) { - DefaultSystemLog.getLog().error("转发文件异常", e); + log.error("转发文件异常", e); } }); // @author jzy add timeout @@ -448,7 +450,7 @@ public class NodeForward { urlQuery.add("name", URLUtil.encode(nodeModel.getLoginName())); urlQuery.add("password", URLUtil.encode(nodeModel.getLoginPwd())); String format = StrUtil.format("{}://{}{}?{}", ws, nodeModel.getUrl(), nodeUrl.getUrl(), urlQuery.toString()); - DefaultSystemLog.getLog().debug("web socket url:{}", format); + log.debug("web socket url:{}", format); return format; } @@ -462,7 +464,7 @@ public class NodeForward { int status = response.getStatus(); String body = response.body(); if (status != HttpStatus.HTTP_OK) { - DefaultSystemLog.getLog().warn("{} 响应异常 状态码错误:{} {}", nodeModel.getName(), status, body); + log.warn("{} 响应异常 状态码错误:{} {}", nodeModel.getName(), status, body); throw new AgentException(nodeModel.getName() + " 节点响应异常,状态码错误:" + status); } return toJsonMessage(body); diff --git a/modules/server/src/main/java/io/jpom/controller/InstallController.java b/modules/server/src/main/java/io/jpom/controller/InstallController.java index fc45df43c..95de0b537 100644 --- a/modules/server/src/main/java/io/jpom/controller/InstallController.java +++ b/modules/server/src/main/java/io/jpom/controller/InstallController.java @@ -41,6 +41,7 @@ import io.jpom.model.dto.UserLoginDto; import io.jpom.service.user.UserBindWorkspaceService; import io.jpom.service.user.UserService; import io.jpom.util.TwoFactorAuthUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.PostMapping; @@ -55,6 +56,7 @@ import java.util.List; * @since 2019/2/22 */ @RestController +@Slf4j public class InstallController extends BaseServerController { @@ -108,7 +110,7 @@ public class InstallController extends BaseServerController { BaseServerController.resetInfo(userModel); userService.insert(userModel); } catch (Exception e) { - DefaultSystemLog.getLog().error("初始化用户失败", e); + log.error("初始化用户失败", e); return JsonMessage.getString(400, "初始化失败:" + e.getMessage()); } //自动登录 diff --git a/modules/server/src/main/java/io/jpom/controller/build/RepositoryController.java b/modules/server/src/main/java/io/jpom/controller/build/RepositoryController.java index 633608389..846e5ff30 100644 --- a/modules/server/src/main/java/io/jpom/controller/build/RepositoryController.java +++ b/modules/server/src/main/java/io/jpom/controller/build/RepositoryController.java @@ -52,6 +52,7 @@ import io.jpom.plugin.*; import io.jpom.service.dblog.BuildInfoService; import io.jpom.service.dblog.RepositoryService; import io.jpom.system.JpomRuntimeException; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.GetMapping; @@ -71,6 +72,7 @@ import java.util.stream.Collectors; */ @RestController @Feature(cls = ClassFeature.BUILD_REPOSITORY) +@Slf4j public class RepositoryController extends BaseServerController { private final RepositoryService repositoryService; @@ -143,7 +145,7 @@ public class RepositoryController extends BaseServerController { } catch (JpomRuntimeException jpomRuntimeException) { throw jpomRuntimeException; } catch (Exception e) { - DefaultSystemLog.getLog().warn("获取仓库分支失败", e); + log.warn("获取仓库分支失败", e); return JsonMessage.toJson(500, "无法连接此仓库," + e.getMessage()); } } @@ -423,7 +425,7 @@ public class RepositoryController extends BaseServerController { if (StrUtil.startWith(repositoryModelReq.getRsaPrv(), URLUtil.FILE_URL_PREFIX)) { String rsaPath = StrUtil.removePrefix(repositoryModelReq.getRsaPrv(), URLUtil.FILE_URL_PREFIX); if (!FileUtil.exist(rsaPath)) { - DefaultSystemLog.getLog().warn("there is no rsa file... {}", rsaPath); + log.warn("there is no rsa file... {}", rsaPath); return false; } } else { diff --git a/modules/server/src/main/java/io/jpom/controller/node/NodeUpdateController.java b/modules/server/src/main/java/io/jpom/controller/node/NodeUpdateController.java index 5049a1b03..8cd131118 100644 --- a/modules/server/src/main/java/io/jpom/controller/node/NodeUpdateController.java +++ b/modules/server/src/main/java/io/jpom/controller/node/NodeUpdateController.java @@ -46,6 +46,7 @@ import io.jpom.permission.Feature; import io.jpom.permission.MethodFeature; import io.jpom.service.system.SystemParametersServer; import io.jpom.system.ServerConfigBean; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.GetMapping; @@ -69,6 +70,7 @@ import java.util.stream.Collectors; @RequestMapping(value = "/node") @SystemPermission(superUser = true) @Feature(cls = ClassFeature.UPGRADE_NODE_LIST) +@Slf4j public class NodeUpdateController extends BaseServerController { private final SystemParametersServer systemParametersServer; @@ -216,7 +218,7 @@ public class NodeUpdateController extends BaseServerController { try { nodeService.testNode(nodeModel); } catch (Exception e) { - DefaultSystemLog.getLog().warn("测试结果:{} {}", nodeModel.getUrl(), e.getMessage()); + log.warn("测试结果:{} {}", nodeModel.getUrl(), e.getMessage()); return JsonMessage.getString(500, "节点连接失败:" + e.getMessage()); } // 插入 diff --git a/modules/server/src/main/java/io/jpom/controller/node/monitor/InternalController.java b/modules/server/src/main/java/io/jpom/controller/node/monitor/InternalController.java index f7f705d84..7e15d8e46 100644 --- a/modules/server/src/main/java/io/jpom/controller/node/monitor/InternalController.java +++ b/modules/server/src/main/java/io/jpom/controller/node/monitor/InternalController.java @@ -52,7 +52,7 @@ public class InternalController extends BaseServerController { @ResponseBody public String getInternalData() { return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_internal_data).toString(); - //DefaultSystemLog.getLog().info("data: {}", data == null ? "" : data.toString()); + //log.info("data: {}", data == null ? "" : data.toString()); // return JsonMessage.getString(200, "success", data); } diff --git a/modules/server/src/main/java/io/jpom/controller/openapi/BuildTriggerApiController.java b/modules/server/src/main/java/io/jpom/controller/openapi/BuildTriggerApiController.java index 2fb08a839..ecfd7a8cd 100644 --- a/modules/server/src/main/java/io/jpom/controller/openapi/BuildTriggerApiController.java +++ b/modules/server/src/main/java/io/jpom/controller/openapi/BuildTriggerApiController.java @@ -46,6 +46,7 @@ import io.jpom.model.data.UserModel; import io.jpom.model.enums.BuildStatus; import io.jpom.service.dblog.BuildInfoService; import io.jpom.service.user.UserService; +import lombok.extern.slf4j.Slf4j; import org.h2.util.StringUtils; import org.springframework.http.MediaType; import org.springframework.util.Assert; @@ -60,6 +61,7 @@ import java.util.stream.Collectors; */ @RestController @NotLogin +@Slf4j public class BuildTriggerApiController extends BaseJpomController { private final BuildInfoService buildInfoService; @@ -188,7 +190,7 @@ public class BuildTriggerApiController extends BaseJpomController { }).collect(Collectors.toList()); return JsonMessage.getString(200, "触发成功", collect); } catch (Exception e) { - DefaultSystemLog.getLog().error("构建触发批量触发异常", e); + log.error("构建触发批量触发异常", e); return JsonMessage.getString(500, "触发异常", e.getMessage()); } } @@ -263,7 +265,7 @@ public class BuildTriggerApiController extends BaseJpomController { }).collect(Collectors.toList()); return JsonMessage.getString(200, "", collect); } catch (Exception e) { - DefaultSystemLog.getLog().error("获取构建状态异常", e); + log.error("获取构建状态异常", e); return JsonMessage.getString(500, "发送异常", e.getMessage()); } } diff --git a/modules/server/src/main/java/io/jpom/controller/openapi/NodeInfoController.java b/modules/server/src/main/java/io/jpom/controller/openapi/NodeInfoController.java index f15cbc8fd..a8c70fc53 100644 --- a/modules/server/src/main/java/io/jpom/controller/openapi/NodeInfoController.java +++ b/modules/server/src/main/java/io/jpom/controller/openapi/NodeInfoController.java @@ -40,6 +40,7 @@ import io.jpom.model.data.NodeModel; import io.jpom.model.data.WorkspaceModel; import io.jpom.service.node.NodeService; import io.jpom.service.system.WorkspaceService; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -56,6 +57,7 @@ import java.util.stream.Collectors; * @since 2019/8/5 */ @RestController +@Slf4j public class NodeInfoController extends AbstractController { private static final Map CACHE_RECEIVE_PUSH = new HashMap<>(); @@ -113,7 +115,7 @@ public class NodeInfoController extends AbstractController { try { nodeService.testNode(model); } catch (Exception e) { - DefaultSystemLog.getLog().warn("测试结果:{} {}", model.getUrl(), e.getMessage()); + log.warn("测试结果:{} {}", model.getUrl(), e.getMessage()); return null; } return model; diff --git a/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectController.java b/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectController.java index 20f3f018b..124ad4d2c 100644 --- a/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectController.java +++ b/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectController.java @@ -53,6 +53,7 @@ import io.jpom.service.node.ProjectInfoCacheService; import io.jpom.system.ConfigBean; import io.jpom.system.ServerConfigBean; import io.jpom.util.StringUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -76,6 +77,7 @@ import java.util.stream.Collectors; @RestController @RequestMapping(value = "/outgiving") @Feature(cls = ClassFeature.OUTGIVING) +@Slf4j public class OutGivingProjectController extends BaseServerController { private final OutGivingServer outGivingServer; @@ -248,7 +250,7 @@ public class OutGivingProjectController extends BaseServerController { OutGivingRun.startRun(outGivingModel.getId(), downloadFile, getUser(), unzip); return JsonMessage.getString(200, "分发成功"); } catch (Exception e) { - DefaultSystemLog.getLog().error("下载远程文件异常", e); + log.error("下载远程文件异常", e); return JsonMessage.getString(500, "下载远程文件失败:" + e.getMessage()); } } diff --git a/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectEditController.java b/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectEditController.java index 2aca03b4c..72fb4fdde 100644 --- a/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectEditController.java +++ b/modules/server/src/main/java/io/jpom/controller/outgiving/OutGivingProjectEditController.java @@ -49,6 +49,7 @@ import io.jpom.permission.MethodFeature; import io.jpom.service.dblog.BuildInfoService; import io.jpom.service.outgiving.OutGivingServer; import io.jpom.service.node.ProjectInfoCacheService; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @@ -68,6 +69,7 @@ import java.util.List; @RestController @RequestMapping(value = "/outgiving") @Feature(cls = ClassFeature.OUTGIVING) +@Slf4j public class OutGivingProjectEditController extends BaseServerController { private final OutGivingWhitelistService outGivingWhitelistService; @@ -210,7 +212,7 @@ public class OutGivingProjectEditController extends BaseServerController { projectInfoCacheService.syncNode(nodeModel, outGivingModel.getId()); } } catch (Exception e) { - DefaultSystemLog.getLog().error("保存分发项目失败", e); + log.error("保存分发项目失败", e); if (!edit) { fail = true; outGivingServer.delByKey(outGivingModel.getId()); @@ -223,7 +225,7 @@ public class OutGivingProjectEditController extends BaseServerController { deleteNodeProject(entry.get(0), userModel, outGivingModel.getId()); } } catch (Exception e) { - DefaultSystemLog.getLog().error("还原项目失败", e); + log.error("还原项目失败", e); } } } diff --git a/modules/server/src/main/java/io/jpom/controller/ssh/SshController.java b/modules/server/src/main/java/io/jpom/controller/ssh/SshController.java index f92e83eac..17c3f2b20 100644 --- a/modules/server/src/main/java/io/jpom/controller/ssh/SshController.java +++ b/modules/server/src/main/java/io/jpom/controller/ssh/SshController.java @@ -179,8 +179,8 @@ public class SshController extends BaseServerController { sshModel.setConnectType(connectType.name()); // 获取允许编辑的后缀 String allowEditSuffix = getParameter("allowEditSuffix"); - int timeOut = getParameterInt("timeOut", 5); - sshModel.setTimeOut(timeOut); + int timeout = getParameterInt("timeout", 5); + sshModel.setTimeout(timeout); List allowEditSuffixList = AgentWhitelist.parseToList(allowEditSuffix, "允许编辑的文件后缀不能为空"); sshModel.allowEditSuffix(allowEditSuffixList); try { @@ -253,7 +253,7 @@ public class SshController extends BaseServerController { String javaVersion = sshService.checkCommand(model, "java"); data.put("javaVersion", javaVersion); } catch (Exception e) { - DefaultSystemLog.getLog().error("检查运行状态异常:{}", e.getMessage()); + log.error("检查运行状态异常:{}", e.getMessage()); data.put("error", e.getMessage()); } result.put(sshModel.getId(), data); diff --git a/modules/server/src/main/java/io/jpom/controller/ssh/SshFileController.java b/modules/server/src/main/java/io/jpom/controller/ssh/SshFileController.java index b371493cd..d5e52eec2 100644 --- a/modules/server/src/main/java/io/jpom/controller/ssh/SshFileController.java +++ b/modules/server/src/main/java/io/jpom/controller/ssh/SshFileController.java @@ -109,7 +109,7 @@ public class SshFileController extends BaseServerController { try { this.downloadFile(sshModel, path, name, response); } catch (SftpException e) { - DefaultSystemLog.getLog().error("下载失败", e); + log.error("下载失败", e); ServletUtil.write(response, "download error", MediaType.TEXT_HTML_VALUE); } } @@ -376,7 +376,7 @@ public class SshFileController extends BaseServerController { } return JsonMessage.getString(200, "删除成功"); } catch (Exception e) { - DefaultSystemLog.getLog().error("ssh删除文件异常", e); + log.error("ssh删除文件异常", e); return JsonMessage.getString(400, "删除失败:" + e.getMessage()); } finally { IoUtil.close(sftp); @@ -482,7 +482,7 @@ public class SshFileController extends BaseServerController { } } catch (Exception e) { - DefaultSystemLog.getLog().error("ssh上传文件异常", e); + log.error("ssh上传文件异常", e); return JsonMessage.getString(400, "上传失败:" + e.getMessage()); } finally { JschUtil.close(channel); diff --git a/modules/server/src/main/java/io/jpom/controller/ssh/SshInstallAgentController.java b/modules/server/src/main/java/io/jpom/controller/ssh/SshInstallAgentController.java index 527c6698a..201a47b80 100644 --- a/modules/server/src/main/java/io/jpom/controller/ssh/SshInstallAgentController.java +++ b/modules/server/src/main/java/io/jpom/controller/ssh/SshInstallAgentController.java @@ -53,6 +53,7 @@ import io.jpom.system.ConfigBean; import io.jpom.system.ExtConfigBean; import io.jpom.system.ServerConfigBean; import io.jpom.util.StringUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.env.YamlPropertySourceLoader; import org.springframework.core.env.PropertySource; import org.springframework.core.io.FileUrlResource; @@ -80,6 +81,7 @@ import java.util.zip.ZipFile; @RestController @RequestMapping(value = "node/ssh") @Feature(cls = ClassFeature.SSH) +@Slf4j public class SshInstallAgentController extends BaseServerController { private final SshService sshService; @@ -216,7 +218,7 @@ public class SshInstallAgentController extends BaseServerController { } String command = StrUtil.format("{}bash {} start upgrade", chmod, shPtah); String result = sshService.exec(sshModel, command); - DefaultSystemLog.getLog().debug("ssh install agent node {} {}", command, result); + log.debug("ssh install agent node {} {}", command, result); // 休眠 5 秒, 尝试 5 次 int waitCount = getParameterInt("waitCount", 5); this.loopCheck(waitCount, nodeModel, sshModel, path, result); @@ -251,7 +253,7 @@ public class SshInstallAgentController extends BaseServerController { waitCount = Math.max(waitCount, 5); //int time = 3; while (--waitCount >= 0) { - //DefaultSystemLog.getLog().debug("there is left {} / 3 times try to get authorize info", waitCount); + //log.debug("there is left {} / 3 times try to get authorize info", waitCount); ThreadUtil.sleep(5, TimeUnit.SECONDS); if (StrUtil.hasEmpty(nodeModel.getLoginName(), nodeModel.getLoginPwd())) { String error = this.getAuthorize(sshModel, nodeModel, path); @@ -283,7 +285,7 @@ public class SshInstallAgentController extends BaseServerController { nodeModel.setLoginPwd(autoUser.getAgentPwd()); nodeModel.setLoginName(autoUser.getAgentName()); } catch (Exception e) { - DefaultSystemLog.getLog().error("拉取授权信息失败:{}", e.getMessage()); + log.error("拉取授权信息失败:{}", e.getMessage()); return "获取授权信息失败,请检查对应的插件端运行状态" + e.getMessage(); } finally { FileUtil.del(saveFile); diff --git a/modules/server/src/main/java/io/jpom/controller/system/BackupInfoController.java b/modules/server/src/main/java/io/jpom/controller/system/BackupInfoController.java index ed462da30..328e62342 100644 --- a/modules/server/src/main/java/io/jpom/controller/system/BackupInfoController.java +++ b/modules/server/src/main/java/io/jpom/controller/system/BackupInfoController.java @@ -216,7 +216,7 @@ public class BackupInfoController extends BaseServerController { // 检查备份文件是否存在 File file = new File(backupInfoModel.getFilePath()); if (!FileUtil.exist(file)) { - //DefaultSystemLog.getLog().error("文件不存在,无法下载...backupId: {}", id); + //log.error("文件不存在,无法下载...backupId: {}", id); ServletUtil.write(getResponse(), JsonMessage.getString(404, "文件不存在,无法下载"), ContentType.JSON.toString()); return; } diff --git a/modules/server/src/main/java/io/jpom/controller/system/SystemConfigController.java b/modules/server/src/main/java/io/jpom/controller/system/SystemConfigController.java index 6c614be83..57627fec3 100644 --- a/modules/server/src/main/java/io/jpom/controller/system/SystemConfigController.java +++ b/modules/server/src/main/java/io/jpom/controller/system/SystemConfigController.java @@ -55,6 +55,7 @@ import io.jpom.service.system.SystemParametersServer; import io.jpom.system.ExtConfigBean; import io.jpom.system.extconf.DbExtConfig; import io.jpom.system.init.InitDb; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.env.YamlPropertySourceLoader; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; @@ -83,6 +84,7 @@ import java.util.List; @RequestMapping(value = "system") @Feature(cls = ClassFeature.SYSTEM_CONFIG) @SystemPermission +@Slf4j public class SystemConfigController extends BaseServerController { private final SystemParametersServer systemParametersServer; @@ -134,7 +136,7 @@ public class SystemConfigController extends BaseServerController { ByteArrayResource resource = new ByteArrayResource(content.replace("\t", " ").getBytes(StandardCharsets.UTF_8)); yamlPropertySourceLoader.load("test", resource); } catch (Exception e) { - DefaultSystemLog.getLog().warn("内容格式错误,请检查修正", e); + log.warn("内容格式错误,请检查修正", e); return JsonMessage.getString(500, "内容格式错误,请检查修正:" + e.getMessage()); } boolean restartBool = Convert.toBool(restart, false); diff --git a/modules/server/src/main/java/io/jpom/controller/user/UserBasicInfoController.java b/modules/server/src/main/java/io/jpom/controller/user/UserBasicInfoController.java index 916a546a2..bd8289f08 100644 --- a/modules/server/src/main/java/io/jpom/controller/user/UserBasicInfoController.java +++ b/modules/server/src/main/java/io/jpom/controller/user/UserBasicInfoController.java @@ -42,6 +42,7 @@ import io.jpom.service.system.SystemParametersServer; import io.jpom.service.user.UserBindWorkspaceService; import io.jpom.service.user.UserService; import io.jpom.util.TwoFactorAuthUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.GetMapping; @@ -61,6 +62,7 @@ import java.util.concurrent.TimeUnit; */ @RestController @RequestMapping(value = "/user") +@Slf4j public class UserBasicInfoController extends BaseServerController { private static final TimedCache CACHE = new TimedCache<>(TimeUnit.MINUTES.toMillis(30)); @@ -144,7 +146,7 @@ public class UserBasicInfoController extends BaseServerController { try { EmailUtil.send(email, "Jpom 验证码", "验证码是:" + randomInt); } catch (Exception e) { - DefaultSystemLog.getLog().error("发送失败", e); + log.error("发送失败", e); return JsonMessage.getString(500, "发送邮件失败:" + e.getMessage()); } CACHE.put(email, randomInt); diff --git a/modules/server/src/main/java/io/jpom/controller/user/UserInfoController.java b/modules/server/src/main/java/io/jpom/controller/user/UserInfoController.java index a00e0ddbb..908c928e9 100644 --- a/modules/server/src/main/java/io/jpom/controller/user/UserInfoController.java +++ b/modules/server/src/main/java/io/jpom/controller/user/UserInfoController.java @@ -33,6 +33,7 @@ import io.jpom.model.data.UserBindWorkspaceModel; import io.jpom.model.data.UserModel; import io.jpom.service.user.UserBindWorkspaceService; import io.jpom.service.user.UserService; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.GetMapping; @@ -50,6 +51,7 @@ import java.util.List; */ @RestController @RequestMapping(value = "/user") +@Slf4j public class UserInfoController extends BaseServerController { private final UserService userService; @@ -84,7 +86,7 @@ public class UserInfoController extends BaseServerController { getSession().invalidate(); return JsonMessage.getString(200, "修改密码成功!"); } catch (Exception e) { - DefaultSystemLog.getLog().error(e.getMessage(), e); + log.error(e.getMessage(), e); return JsonMessage.getString(500, "系统异常:" + e.getMessage()); } } diff --git a/modules/server/src/main/java/io/jpom/model/data/SshModel.java b/modules/server/src/main/java/io/jpom/model/data/SshModel.java index 84bee6671..db2cdfe04 100644 --- a/modules/server/src/main/java/io/jpom/model/data/SshModel.java +++ b/modules/server/src/main/java/io/jpom/model/data/SshModel.java @@ -83,7 +83,7 @@ public class SshModel extends BaseWorkspaceModel { /** * 节点超时时间 */ - private Integer timeOut; + private Integer timeout; public SshModel(String id) { this.setId(id); @@ -127,11 +127,11 @@ public class SshModel extends BaseWorkspaceModel { * * @return 最小值 1 分钟 */ - public int timeOut() { - if (this.timeOut == null) { + public int timeout() { + if (this.timeout == null) { return 5; } - return Math.max(1, this.timeOut); + return Math.max(1, this.timeout); } public Charset getCharsetT() { diff --git a/modules/server/src/main/java/io/jpom/monitor/MonitorItem.java b/modules/server/src/main/java/io/jpom/monitor/MonitorItem.java index 0467e033a..11e029f10 100644 --- a/modules/server/src/main/java/io/jpom/monitor/MonitorItem.java +++ b/modules/server/src/main/java/io/jpom/monitor/MonitorItem.java @@ -50,6 +50,7 @@ import io.jpom.service.monitor.MonitorService; import io.jpom.service.node.NodeService; import io.jpom.service.node.ProjectInfoCacheService; import io.jpom.service.user.UserService; +import lombok.extern.slf4j.Slf4j; import java.util.HashMap; import java.util.List; @@ -62,6 +63,7 @@ import java.util.stream.Collectors; * @author bwcx_jzy * @since 2021/12/14 */ +@Slf4j public class MonitorItem implements Task { @@ -140,7 +142,7 @@ public class MonitorItem implements Task { context = jsonMessage.toString(); } } catch (Exception e) { - DefaultSystemLog.getLog().error("监控 {} 节点异常 {}", nodeModel.getName(), e.getMessage()); + log.error("监控 {} 节点异常 {}", nodeModel.getName(), e.getMessage()); // title = StrUtil.format("【{}】节点的运行状态异常", nodeModel.getName()); context = ExceptionUtil.stacktraceToString(e); @@ -207,7 +209,7 @@ public class MonitorItem implements Task { } context = "重启结果:" + reJson; } catch (Exception e) { - DefaultSystemLog.getLog().error("执行重启操作", e); + log.error("执行重启操作", e); title = StrUtil.format("【{}】节点的【{}】项目{}已经停止,重启操作异常", nodeModel.getName(), id, copyMsg); context = ExceptionUtil.stacktraceToString(e); } @@ -296,7 +298,7 @@ public class MonitorItem implements Task { plugin.execute(webhook, map); dbMonitorNotifyLogService.updateStatus(logId, true, null); } catch (Exception e) { - DefaultSystemLog.getLog().error("WebHooks 调用错误", e); + log.error("WebHooks 调用错误", e); dbMonitorNotifyLogService.updateStatus(logId, false, ExceptionUtil.stacktraceToString(e)); } }); @@ -361,7 +363,7 @@ public class MonitorItem implements Task { NotifyUtil.send(notify, title, context); dbMonitorNotifyLogService.updateStatus(logId, true, null); } catch (Exception e) { - DefaultSystemLog.getLog().error("发送报警通知异常", e); + log.error("发送报警通知异常", e); dbMonitorNotifyLogService.updateStatus(logId, false, ExceptionUtil.stacktraceToString(e)); } }); diff --git a/modules/server/src/main/java/io/jpom/outgiving/OutGivingItemRun.java b/modules/server/src/main/java/io/jpom/outgiving/OutGivingItemRun.java index 8823deb00..eae3eb8b6 100644 --- a/modules/server/src/main/java/io/jpom/outgiving/OutGivingItemRun.java +++ b/modules/server/src/main/java/io/jpom/outgiving/OutGivingItemRun.java @@ -43,6 +43,7 @@ import io.jpom.model.log.OutGivingLog; import io.jpom.service.outgiving.DbOutGivingLogService; import io.jpom.service.node.NodeService; import io.jpom.service.outgiving.OutGivingServer; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.Assert; import java.io.File; @@ -54,6 +55,7 @@ import java.util.stream.Collectors; * @author bwcx_jzy * @since 2021/12/10 */ +@Slf4j public class OutGivingItemRun implements Callable { private final String outGivingId; @@ -107,7 +109,7 @@ public class OutGivingItemRun implements Callable { } this.updateStatus(this.outGivingId, this.outGivingNodeProject, result, jsonMessage.toString()); } catch (Exception e) { - DefaultSystemLog.getLog().error(this.outGivingNodeProject.getNodeId() + " " + this.outGivingNodeProject.getProjectId() + " " + "分发异常保存", e); + log.error(this.outGivingNodeProject.getNodeId() + " " + this.outGivingNodeProject.getProjectId() + " " + "分发异常保存", e); result = OutGivingNodeProject.Status.Fail; this.updateStatus(this.outGivingId, this.outGivingNodeProject, result, "error:" + e.getMessage()); } diff --git a/modules/server/src/main/java/io/jpom/service/dblog/BuildInfoService.java b/modules/server/src/main/java/io/jpom/service/dblog/BuildInfoService.java index 88bda7108..36e7e042c 100644 --- a/modules/server/src/main/java/io/jpom/service/dblog/BuildInfoService.java +++ b/modules/server/src/main/java/io/jpom/service/dblog/BuildInfoService.java @@ -37,6 +37,7 @@ import io.jpom.model.enums.BuildReleaseMethod; import io.jpom.model.enums.BuildStatus; import io.jpom.service.IStatusRecover; import io.jpom.service.h2db.BaseGroupService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; @@ -49,6 +50,7 @@ import java.util.List; * @since 2021-08-10 **/ @Service +@Slf4j public class BuildInfoService extends BaseGroupService implements ICron, IStatusRecover { /** @@ -119,7 +121,7 @@ public class BuildInfoService extends BaseGroupService implement CronUtils.remove(taskId); return false; } - DefaultSystemLog.getLog().debug("start build cron {} {} {}", id, buildInfoModel.getName(), autoBuildCron); + log.debug("start build cron {} {} {}", id, buildInfoModel.getName(), autoBuildCron); CronUtils.upsert(taskId, autoBuildCron, new CronTask(id, autoBuildCron)); return true; } diff --git a/modules/server/src/main/java/io/jpom/service/dblog/DbUserOperateLogService.java b/modules/server/src/main/java/io/jpom/service/dblog/DbUserOperateLogService.java index f9896c436..4d041cdd7 100644 --- a/modules/server/src/main/java/io/jpom/service/dblog/DbUserOperateLogService.java +++ b/modules/server/src/main/java/io/jpom/service/dblog/DbUserOperateLogService.java @@ -48,6 +48,7 @@ import io.jpom.service.monitor.MonitorUserOptService; import io.jpom.service.system.WorkspaceService; import io.jpom.service.user.UserService; import io.jpom.system.init.OperateLogController; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; @@ -63,6 +64,7 @@ import java.util.stream.Collectors; * @since 2019/7/20 */ @Service +@Slf4j public class DbUserOperateLogService extends BaseWorkspaceService { private final MonitorUserOptService monitorUserOptService; @@ -204,7 +206,7 @@ public class DbUserOperateLogService extends BaseWorkspaceService extends BaseDbCommonService { public BaseDbService() { @@ -374,7 +376,7 @@ public abstract class BaseDbService extends BaseDbCommonS entity.set(timeColumn, "< " + time); int count = super.del(entity); if (count > 0) { - DefaultSystemLog.getLog().debug("{} 清理了 {}条数据", super.getTableName(), count); + log.debug("{} 清理了 {}条数据", super.getTableName(), count); } }); } @@ -431,7 +433,7 @@ public abstract class BaseDbService extends BaseDbCommonS } catch (java.lang.IllegalStateException illegalStateException) { return 0L; } catch (Exception e) { - DefaultSystemLog.getLog().error("查询数据错误", e); + log.error("查询数据错误", e); return 0L; } if (pageResult.isEmpty()) { diff --git a/modules/server/src/main/java/io/jpom/service/h2db/BaseNodeService.java b/modules/server/src/main/java/io/jpom/service/h2db/BaseNodeService.java index d0cb9e596..aacd234e9 100644 --- a/modules/server/src/main/java/io/jpom/service/h2db/BaseNodeService.java +++ b/modules/server/src/main/java/io/jpom/service/h2db/BaseNodeService.java @@ -44,6 +44,7 @@ import io.jpom.service.node.NodeService; import io.jpom.service.system.WorkspaceService; import io.jpom.system.AgentException; import io.jpom.system.AuthorizeException; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.Assert; import javax.servlet.http.HttpServletRequest; @@ -57,6 +58,7 @@ import java.util.stream.Collectors; * @author bwcx_jzy * @since 2021/12/5 */ +@Slf4j public abstract class BaseNodeService extends BaseWorkspaceService { protected final NodeService nodeService; @@ -94,7 +96,7 @@ public abstract class BaseNodeService extends BaseWorks ThreadUtil.execute(() -> { List list = nodeService.list(); if (CollUtil.isEmpty(list)) { - DefaultSystemLog.getLog().debug("没有任何节点"); + log.debug("没有任何节点"); return; } // 排序 避免项目被个节点绑定 @@ -132,7 +134,7 @@ public abstract class BaseNodeService extends BaseWorks public String syncExecuteNode(NodeModel nodeModel) { String nodeModelName = nodeModel.getName(); if (!nodeModel.isOpenStatus()) { - DefaultSystemLog.getLog().debug("{} 节点未启用", nodeModelName); + log.debug("{} 节点未启用", nodeModelName); return "节点未启用"; } try { @@ -142,7 +144,7 @@ public abstract class BaseNodeService extends BaseWorks entity.set("nodeId", nodeModel.getId()); int del = super.del(entity); // - DefaultSystemLog.getLog().debug("{} 节点没有拉取到任何{}", nodeModelName, dataName); + log.debug("{} 节点没有拉取到任何{}", nodeModelName, dataName); return "节点没有拉取到任何" + dataName; } // 查询现在存在的项目 @@ -185,7 +187,7 @@ public abstract class BaseNodeService extends BaseWorks CollUtil.size(cacheAll), dataName, CollUtil.size(models), dataName, CollUtil.size(strings)); - DefaultSystemLog.getLog().debug(format); + log.debug(format); return format; } catch (Exception e) { return this.checkException(e, nodeModelName); @@ -197,14 +199,14 @@ public abstract class BaseNodeService extends BaseWorks protected String checkException(Exception e, String nodeModelName) { if (e instanceof AgentException) { AgentException agentException = (AgentException) e; - DefaultSystemLog.getLog().error("{} 同步失败 {}", nodeModelName, agentException.getMessage()); + log.error("{} 同步失败 {}", nodeModelName, agentException.getMessage()); return "同步失败" + agentException.getMessage(); } else if (e instanceof AuthorizeException) { AuthorizeException authorizeException = (AuthorizeException) e; - DefaultSystemLog.getLog().error("{} 同步失败 {}", nodeModelName, authorizeException.getMessage()); + log.error("{} 同步失败 {}", nodeModelName, authorizeException.getMessage()); return "同步失败" + authorizeException.getMessage(); } - DefaultSystemLog.getLog().error("同步节点" + dataName + "失败:" + nodeModelName, e); + log.error("同步节点" + dataName + "失败:" + nodeModelName, e); return "同步节点" + dataName + "失败" + e.getMessage(); } @@ -216,7 +218,7 @@ public abstract class BaseNodeService extends BaseWorks public void syncNode(final NodeModel nodeModel, String id) { String nodeModelName = nodeModel.getName(); if (!nodeModel.isOpenStatus()) { - DefaultSystemLog.getLog().debug("{} 节点未启用", nodeModelName); + log.debug("{} 节点未启用", nodeModelName); return; } ThreadUtil.execute(() -> { diff --git a/modules/server/src/main/java/io/jpom/service/monitor/MonitorService.java b/modules/server/src/main/java/io/jpom/service/monitor/MonitorService.java index dd89a6665..a0e7ae694 100644 --- a/modules/server/src/main/java/io/jpom/service/monitor/MonitorService.java +++ b/modules/server/src/main/java/io/jpom/service/monitor/MonitorService.java @@ -28,6 +28,7 @@ import io.jpom.cron.ICron; import io.jpom.model.data.MonitorModel; import io.jpom.monitor.MonitorItem; import io.jpom.service.h2db.BaseWorkspaceService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; @@ -39,6 +40,7 @@ import java.util.List; * @author Arno */ @Service +@Slf4j public class MonitorService extends BaseWorkspaceService implements ICron { @Override @@ -88,7 +90,7 @@ public class MonitorService extends BaseWorkspaceService implement CronUtils.remove(taskId); return false; } - DefaultSystemLog.getLog().debug("start monitor cron {} {} {}", id, monitorModel.getName(), autoExecCron); + log.debug("start monitor cron {} {} {}", id, monitorModel.getName(), autoExecCron); CronUtils.upsert(taskId, autoExecCron, new MonitorItem(id)); return true; } diff --git a/modules/server/src/main/java/io/jpom/service/node/NodeService.java b/modules/server/src/main/java/io/jpom/service/node/NodeService.java index d4079e28e..7dc5fa73c 100644 --- a/modules/server/src/main/java/io/jpom/service/node/NodeService.java +++ b/modules/server/src/main/java/io/jpom/service/node/NodeService.java @@ -362,7 +362,7 @@ public class NodeService extends BaseGroupService { // where.setUrl(info.getUrl()); // int updateCount = super.update(super.dataBeanToEntity(update), super.dataBeanToEntity(where)); // if (updateCount > 1) { -// DefaultSystemLog.getLog().debug("update duplicate node {} {}", info.getUrl(), updateCount); +// log.debug("update duplicate node {} {}", info.getUrl(), updateCount); // } } diff --git a/modules/server/src/main/java/io/jpom/service/node/command/CommandService.java b/modules/server/src/main/java/io/jpom/service/node/command/CommandService.java index d69c94fbd..07ba0e858 100644 --- a/modules/server/src/main/java/io/jpom/service/node/command/CommandService.java +++ b/modules/server/src/main/java/io/jpom/service/node/command/CommandService.java @@ -47,6 +47,7 @@ import io.jpom.model.data.UserModel; import io.jpom.service.h2db.BaseWorkspaceService; import io.jpom.service.node.ssh.SshService; import io.jpom.service.system.WorkspaceEnvVarService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -67,6 +68,7 @@ import java.util.stream.Collectors; * @since : 2021/12/6 22:11 */ @Service +@Slf4j public class CommandService extends BaseWorkspaceService implements ICron { private final SshService sshService; @@ -122,7 +124,7 @@ public class CommandService extends BaseWorkspaceService implement CronUtils.remove(taskId); return false; } - DefaultSystemLog.getLog().debug("start ssh command cron {} {} {}", id, buildInfoModel.getName(), autoExecCron); + log.debug("start ssh command cron {} {} {}", id, buildInfoModel.getName(), autoExecCron); CronUtils.upsert(taskId, autoExecCron, new CommandService.CronTask(id)); return true; } @@ -151,7 +153,7 @@ public class CommandService extends BaseWorkspaceService implement CommandModel commandModel = CommandService.this.getByKey(this.id); CommandService.this.executeBatch(commandModel, commandModel.getDefParams(), commandModel.getSshIds(), 1); } catch (Exception e) { - DefaultSystemLog.getLog().error("触发自动执行命令模版异常", e); + log.error("触发自动执行命令模版异常", e); } finally { BaseServerController.removeEmpty(); } @@ -226,7 +228,7 @@ public class CommandService extends BaseWorkspaceService implement try { this.execute(commandModel, commandExecLogModel, sshModel, commandParamsLine); } catch (Exception e) { - DefaultSystemLog.getLog().error("命令模版执行链接异常", e); + log.error("命令模版执行链接异常", e); this.updateStatus(commandExecLogModel.getId(), CommandExecLogModel.Status.SESSION_ERROR); } }); @@ -266,13 +268,13 @@ public class CommandService extends BaseWorkspaceService implement InputStream in = null; try { - channel.connect((int) TimeUnit.SECONDS.toMillis(sshModel.timeOut())); + channel.connect((int) TimeUnit.SECONDS.toMillis(sshModel.timeout())); in = channel.getInputStream(); IoUtil.readLines(in, charset, (LineHandler) line -> this.appendLine(outputStream, line)); // 更新状态 this.updateStatus(commandExecLogModel.getId(), CommandExecLogModel.Status.DONE); } catch (Exception e) { - DefaultSystemLog.getLog().error("执行命令错误", e); + log.error("执行命令错误", e); // 更新状态 this.updateStatus(commandExecLogModel.getId(), CommandExecLogModel.Status.ERROR); // 记录错误日志 @@ -312,7 +314,7 @@ public class CommandService extends BaseWorkspaceService implement outputStream.write(LINE_BYTES); outputStream.flush(); } catch (IOException e) { - DefaultSystemLog.getLog().warn("command log append line:{}", e.getMessage()); + log.warn("command log append line:{}", e.getMessage()); } } diff --git a/modules/server/src/main/java/io/jpom/service/node/script/NodeScriptExecuteLogServer.java b/modules/server/src/main/java/io/jpom/service/node/script/NodeScriptExecuteLogServer.java index 6c0f9079e..1acc53634 100644 --- a/modules/server/src/main/java/io/jpom/service/node/script/NodeScriptExecuteLogServer.java +++ b/modules/server/src/main/java/io/jpom/service/node/script/NodeScriptExecuteLogServer.java @@ -105,7 +105,7 @@ public class NodeScriptExecuteLogServer extends BaseNodeService syncExecuteNodeInc(NodeModel nodeModel) { String nodeModelName = nodeModel.getName(); if (!nodeModel.isOpenStatus()) { - DefaultSystemLog.getLog().debug("{} 节点未启用", nodeModelName); + log.debug("{} 节点未启用", nodeModelName); return null; } try { @@ -133,7 +133,7 @@ public class NodeScriptExecuteLogServer extends BaseNodeService { */ public static Session getSessionByModel(SshModel sshModel) { Session session = null; - int timeOut = (int) TimeUnit.SECONDS.toMillis(sshModel.timeOut()); + int timeout = (int) TimeUnit.SECONDS.toMillis(sshModel.timeout()); SshModel.ConnectType connectType = sshModel.connectType(); if (connectType == SshModel.ConnectType.PASS) { - session = JschUtil.openSession(sshModel.getHost(), sshModel.getPort(), sshModel.getUser(), sshModel.getPassword(), timeOut); + session = JschUtil.openSession(sshModel.getHost(), sshModel.getPort(), sshModel.getUser(), sshModel.getPassword(), timeout); } else if (connectType == SshModel.ConnectType.PUBKEY) { File rsaFile = null; @@ -130,11 +132,11 @@ public class SshService extends BaseWorkspaceService { Assert.state(FileUtil.isFile(rsaFile), "私钥文件不存在:" + FileUtil.getAbsolutePath(rsaFile)); session = JschUtil.createSession(sshModel.getHost(), sshModel.getPort(), sshModel.getUser(), FileUtil.getAbsolutePath(rsaFile), sshModel.password()); - try { - session.connect(timeOut); - } catch (JSchException e) { - throw new JschRuntimeException(e); - } + } + try { + session.connect(timeout); + } catch (JSchException e) { + throw new JschRuntimeException(e); } } else { throw new IllegalArgumentException("不支持的模式"); @@ -351,8 +353,9 @@ public class SshService extends BaseWorkspaceService { try { session = getSessionByModel(sshModel); channel = (ChannelSftp) JschUtil.openChannel(session, ChannelType.SFTP); - Sftp sftp = new Sftp(channel, sshModel.getCharsetT()); - sftp.syncUpload(desc, remotePath); + try (Sftp sftp = new Sftp(channel, sshModel.getCharsetT())) { + sftp.syncUpload(desc, remotePath); + } //uploadDir(channel, remotePath, desc, sshModel.getCharsetT()); } finally { JschUtil.close(channel); @@ -366,17 +369,17 @@ public class SshService extends BaseWorkspaceService { * @param sshModel 实体 * @param remoteFile 远程文件 * @param save 文件对象 - * @throws FileNotFoundException io - * @throws SftpException sftp + * @throws IOException io + * @throws SftpException sftp */ - public void download(SshModel sshModel, String remoteFile, File save) throws FileNotFoundException, SftpException { + public void download(SshModel sshModel, String remoteFile, File save) throws IOException, SftpException { Session session = null; ChannelSftp channel = null; OutputStream output = null; try { session = getSessionByModel(sshModel); channel = (ChannelSftp) JschUtil.openChannel(session, ChannelType.SFTP); - output = new FileOutputStream(save); + output = Files.newOutputStream(save.toPath()); channel.get(remoteFile, output); } finally { IoUtil.close(output); diff --git a/modules/server/src/main/java/io/jpom/service/script/ScriptServer.java b/modules/server/src/main/java/io/jpom/service/script/ScriptServer.java index bff3ca1e0..53094039f 100644 --- a/modules/server/src/main/java/io/jpom/service/script/ScriptServer.java +++ b/modules/server/src/main/java/io/jpom/service/script/ScriptServer.java @@ -34,6 +34,7 @@ import io.jpom.model.script.ScriptExecuteLogModel; import io.jpom.model.script.ScriptModel; import io.jpom.service.h2db.BaseWorkspaceService; import io.jpom.socket.ScriptProcessBuilder; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; @@ -44,6 +45,7 @@ import java.util.List; * @since 2022/1/19 */ @Service +@Slf4j public class ScriptServer extends BaseWorkspaceService implements ICron { @Override @@ -91,7 +93,7 @@ public class ScriptServer extends BaseWorkspaceService implements I CronUtils.remove(taskId); return false; } - DefaultSystemLog.getLog().debug("start script cron {} {} {}", id, scriptModel.getName(), autoExecCron); + log.debug("start script cron {} {} {}", id, scriptModel.getName(), autoExecCron); CronUtils.upsert(taskId, autoExecCron, new CronTask(id)); return true; } @@ -120,7 +122,7 @@ public class ScriptServer extends BaseWorkspaceService implements I // 执行 ScriptProcessBuilder.create(scriptServerItem, nodeScriptExecLogModel.getId(), scriptServerItem.getDefArgs()); } catch (Exception e) { - DefaultSystemLog.getLog().error("触发自动执行命令模版异常", e); + log.error("触发自动执行命令模版异常", e); } finally { BaseServerController.removeEmpty(); } diff --git a/modules/server/src/main/java/io/jpom/service/stat/NodeStatService.java b/modules/server/src/main/java/io/jpom/service/stat/NodeStatService.java index 662b0fcde..d75eacf88 100644 --- a/modules/server/src/main/java/io/jpom/service/stat/NodeStatService.java +++ b/modules/server/src/main/java/io/jpom/service/stat/NodeStatService.java @@ -45,6 +45,7 @@ import io.jpom.service.node.NodeService; import io.jpom.system.AgentException; import io.jpom.system.AuthorizeException; import io.jpom.system.ServerExtConfigBean; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.Collection; @@ -61,6 +62,7 @@ import java.util.stream.Collectors; * @since 2022/1/22 */ @Service +@Slf4j public class NodeStatService extends BaseWorkspaceService implements IAsyncLoad, Runnable { private final ServerExtConfigBean serverExtConfigBean; @@ -171,7 +173,7 @@ public class NodeStatService extends BaseWorkspaceService impleme this.save(modelList, 1, e.getMessage()); } catch (Exception e) { this.save(modelList, 1, e.getMessage()); - DefaultSystemLog.getLog().error("获取节点监控信息失败", e); + log.error("获取节点监控信息失败", e); } finally { BaseServerController.removeEmpty(); } diff --git a/modules/server/src/main/java/io/jpom/service/system/WorkspaceService.java b/modules/server/src/main/java/io/jpom/service/system/WorkspaceService.java index 06685cb4d..e19bda1aa 100644 --- a/modules/server/src/main/java/io/jpom/service/system/WorkspaceService.java +++ b/modules/server/src/main/java/io/jpom/service/system/WorkspaceService.java @@ -31,6 +31,7 @@ import io.jpom.model.data.WorkspaceModel; import io.jpom.service.h2db.BaseDbService; import io.jpom.service.h2db.TableName; import io.jpom.service.node.NodeService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.Set; @@ -40,6 +41,7 @@ import java.util.Set; * @since 2021/12/3 */ @Service +@Slf4j public class WorkspaceService extends BaseDbService { /** @@ -57,7 +59,7 @@ public class WorkspaceService extends BaseDbService { defaultWorkspace.setDescription("系统默认的工作空间,不能删除"); super.insert(defaultWorkspace); - DefaultSystemLog.getLog().info("init created default workspace"); + log.info("init created default workspace"); } @@ -75,7 +77,7 @@ public class WorkspaceService extends BaseDbService { NodeService nodeService = SpringUtil.getBean(NodeService.class); int execute = nodeService.execute(sql, Const.WORKSPACE_DEFAULT_ID); if (execute > 0) { - DefaultSystemLog.getLog().info("convertNullWorkspaceId {} {}", tableName.value(), execute); + log.info("convertNullWorkspaceId {} {}", tableName.value(), execute); } } diff --git a/modules/server/src/main/java/io/jpom/socket/BaseHandler.java b/modules/server/src/main/java/io/jpom/socket/BaseHandler.java index 7d6ee73f3..5a6d1bef0 100644 --- a/modules/server/src/main/java/io/jpom/socket/BaseHandler.java +++ b/modules/server/src/main/java/io/jpom/socket/BaseHandler.java @@ -32,6 +32,7 @@ import io.jpom.permission.Feature; import io.jpom.permission.MethodFeature; import io.jpom.system.init.OperateLogController; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.WebSocketSession; @@ -43,6 +44,7 @@ import java.util.Map; * @author bwcx_jzy * @since 2019/8/9 */ +@Slf4j public abstract class BaseHandler extends TextWebSocketHandler { @Override @@ -78,7 +80,7 @@ public abstract class BaseHandler extends TextWebSocketHandler { @Override public void handleTransportError(WebSocketSession session, Throwable exception) { - DefaultSystemLog.getLog().error(session.getId() + "socket 异常", exception); + log.error(session.getId() + "socket 异常", exception); destroy(session); } @@ -98,7 +100,7 @@ public abstract class BaseHandler extends TextWebSocketHandler { try { SocketSessionUtil.send(session, msg); } catch (Exception e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } } @@ -139,7 +141,7 @@ public abstract class BaseHandler extends TextWebSocketHandler { OperateLogController operateLogController = SpringUtil.getBean(OperateLogController.class); operateLogController.log(userInfo, JSONObject.toJSONString(attributes), cacheInfo); } catch (Exception e) { - DefaultSystemLog.getLog().error("记录操作日志异常", e); + log.error("记录操作日志异常", e); } finally { if (proxySession != null) { attributes.put("proxySession", proxySession); diff --git a/modules/server/src/main/java/io/jpom/socket/ProxySession.java b/modules/server/src/main/java/io/jpom/socket/ProxySession.java index b6367f95e..cbdf0e89d 100644 --- a/modules/server/src/main/java/io/jpom/socket/ProxySession.java +++ b/modules/server/src/main/java/io/jpom/socket/ProxySession.java @@ -29,6 +29,7 @@ import cn.jiangzeyin.common.DefaultSystemLog; import cn.jiangzeyin.common.spring.SpringUtil; import com.alibaba.fastjson.JSONObject; import io.jpom.system.init.OperateLogController; +import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; import org.springframework.web.socket.TextMessage; @@ -46,6 +47,7 @@ import java.util.concurrent.TimeUnit; * @author jiangzeyin * @since 2019/4/16 */ +@Slf4j public class ProxySession extends WebSocketClient { private final WebSocketSession session; private final OperateLogController logController; @@ -85,7 +87,7 @@ public class ProxySession extends WebSocketClient { try { session.sendMessage(new TextMessage(message)); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } try { JSONObject jsonObject = JSONObject.parseObject(message); @@ -102,7 +104,7 @@ public class ProxySession extends WebSocketClient { try { session.close(); } catch (IOException e) { - DefaultSystemLog.getLog().error("关闭错误", e); + log.error("关闭错误", e); } } @@ -113,7 +115,7 @@ public class ProxySession extends WebSocketClient { // SocketSessionUtil.send(session, ); } catch (IOException ignored) { } - DefaultSystemLog.getLog().error("发生错误", ex); + log.error("发生错误", ex); } @Override @@ -121,7 +123,7 @@ public class ProxySession extends WebSocketClient { try { super.send(text); } catch (Exception e) { - DefaultSystemLog.getLog().error("转发消息失败", e); + log.error("转发消息失败", e); } } } diff --git a/modules/server/src/main/java/io/jpom/socket/ScriptProcessBuilder.java b/modules/server/src/main/java/io/jpom/socket/ScriptProcessBuilder.java index fce354f8e..0962cd770 100644 --- a/modules/server/src/main/java/io/jpom/socket/ScriptProcessBuilder.java +++ b/modules/server/src/main/java/io/jpom/socket/ScriptProcessBuilder.java @@ -40,6 +40,7 @@ import io.jpom.service.system.WorkspaceEnvVarService; import io.jpom.system.ExtConfigBean; import io.jpom.util.CommandUtil; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.WebSocketSession; import java.io.File; @@ -53,6 +54,7 @@ import java.util.concurrent.ConcurrentHashMap; * @author jiangzeyin * @since 2022/1/19 */ +@Slf4j public class ScriptProcessBuilder extends BaseRunScript implements Runnable { /** * 执行中的缓存 @@ -78,7 +80,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { List command = StrUtil.splitTrim(args, StrUtil.SPACE); command.add(0, script); command.add(0, CommandUtil.EXECUTE_PREFIX); - DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE)); + log.debug(CollUtil.join(command, StrUtil.SPACE)); processBuilder.redirectErrorStream(true); processBuilder.command(command); Map environment = processBuilder.environment(); @@ -119,7 +121,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { try { SocketSessionUtil.send(session, line); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } }); } @@ -178,7 +180,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { this.end(jsonObject.toString()); this.handle("execute done:" + waitFor + " time:" + DateUtil.now()); } catch (Exception e) { - DefaultSystemLog.getLog().error("执行异常", e); + log.error("执行异常", e); this.end("执行异常:" + e.getMessage()); } finally { this.close(); @@ -198,7 +200,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { try { SocketSessionUtil.send(session, msg); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } iterator.remove(); } @@ -220,7 +222,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable { try { SocketSessionUtil.send(session, line); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); iterator.remove(); } } diff --git a/modules/server/src/main/java/io/jpom/socket/ServerWebSocketInterceptor.java b/modules/server/src/main/java/io/jpom/socket/ServerWebSocketInterceptor.java index 01f53f8a1..3ffc72f8c 100644 --- a/modules/server/src/main/java/io/jpom/socket/ServerWebSocketInterceptor.java +++ b/modules/server/src/main/java/io/jpom/socket/ServerWebSocketInterceptor.java @@ -41,6 +41,7 @@ import io.jpom.service.h2db.BaseWorkspaceService; import io.jpom.service.node.NodeService; import io.jpom.service.user.UserBindWorkspaceService; import io.jpom.service.user.UserService; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; @@ -57,6 +58,7 @@ import java.util.Map; * @author jiangzeyin * @since 2019/4/19 */ +@Slf4j public class ServerWebSocketInterceptor implements HandshakeInterceptor { private boolean checkNode(HttpServletRequest httpServletRequest, Map attributes, UserModel userModel) { @@ -79,7 +81,7 @@ public class ServerWebSocketInterceptor implements HandshakeInterceptor { String type = httpServletRequest.getParameter("type"); HandlerType handlerType = EnumUtil.fromString(HandlerType.class, type, null); if (handlerType == null) { - DefaultSystemLog.getLog().warn("传入的类型错误:{}", type); + log.warn("传入的类型错误:{}", type); } return handlerType; } @@ -225,7 +227,7 @@ public class ServerWebSocketInterceptor implements HandshakeInterceptor { @Override public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) { if (exception != null) { - DefaultSystemLog.getLog().error("afterHandshake", exception); + log.error("afterHandshake", exception); } } } diff --git a/modules/server/src/main/java/io/jpom/socket/ServiceFileTailWatcher.java b/modules/server/src/main/java/io/jpom/socket/ServiceFileTailWatcher.java index d495530f1..2477b056a 100644 --- a/modules/server/src/main/java/io/jpom/socket/ServiceFileTailWatcher.java +++ b/modules/server/src/main/java/io/jpom/socket/ServiceFileTailWatcher.java @@ -25,6 +25,7 @@ package io.jpom.socket; import cn.hutool.core.io.FileUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.util.BaseFileTailWatcher; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.WebSocketSession; import java.io.File; @@ -39,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; * @author jiangzeyin * @since 2019/07/21 */ +@Slf4j public class ServiceFileTailWatcher extends BaseFileTailWatcher { private static final ConcurrentHashMap> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); @@ -65,7 +67,7 @@ public class ServiceFileTailWatcher extends BaseFileTailWatcher { try { return new ServiceFileTailWatcher<>(file); } catch (Exception e) { - DefaultSystemLog.getLog().error("创建文件监听失败", e); + log.error("创建文件监听失败", e); return null; } }); diff --git a/modules/server/src/main/java/io/jpom/socket/client/NodeClient.java b/modules/server/src/main/java/io/jpom/socket/client/NodeClient.java index 675e996ce..c9928b813 100644 --- a/modules/server/src/main/java/io/jpom/socket/client/NodeClient.java +++ b/modules/server/src/main/java/io/jpom/socket/client/NodeClient.java @@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONObject; import io.jpom.model.WebSocketMessageModel; import io.jpom.model.data.NodeModel; import io.jpom.system.init.OperateLogController; +import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; import org.springframework.web.socket.TextMessage; @@ -47,6 +48,7 @@ import java.util.concurrent.TimeUnit; * * @author lf */ +@Slf4j public class NodeClient extends WebSocketClient { private final WebSocketSession session; private final OperateLogController logController; @@ -103,7 +105,7 @@ public class NodeClient extends WebSocketClient { session.sendMessage(new TextMessage(message)); } } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败", e); + log.error("发送消息失败", e); } try { JSONObject jsonObject = JSONObject.parseObject(message); @@ -131,7 +133,7 @@ public class NodeClient extends WebSocketClient { try { super.close(); } catch (Exception e) { - DefaultSystemLog.getLog().error("关闭异常", e); + log.error("关闭异常", e); } } @@ -142,6 +144,6 @@ public class NodeClient extends WebSocketClient { @Override public void onError(Exception e) { - DefaultSystemLog.getLog().error("发生异常", e); + log.error("发生异常", e); } } diff --git a/modules/server/src/main/java/io/jpom/socket/handler/BaseTerminalHandler.java b/modules/server/src/main/java/io/jpom/socket/handler/BaseTerminalHandler.java index 21e6049ed..5a58dbdfe 100644 --- a/modules/server/src/main/java/io/jpom/socket/handler/BaseTerminalHandler.java +++ b/modules/server/src/main/java/io/jpom/socket/handler/BaseTerminalHandler.java @@ -25,6 +25,7 @@ package io.jpom.socket.handler; import cn.hutool.core.util.StrUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.socket.BaseHandler; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.BinaryMessage; import org.springframework.web.socket.WebSocketSession; @@ -34,6 +35,7 @@ import java.io.IOException; * @author bwcx_jzy * @since 2022/2/10 */ +@Slf4j public abstract class BaseTerminalHandler extends BaseHandler { protected void sendBinary(WebSocketSession session, String msg) { @@ -42,7 +44,7 @@ public abstract class BaseTerminalHandler extends BaseHandler { } if (!session.isOpen()) { // 会话关闭不能发送消息 @author jzy 21-08-04 - DefaultSystemLog.getLog().warn("回话已经关闭啦,不能发送消息:{}", msg); + log.warn("回话已经关闭啦,不能发送消息:{}", msg); return; } synchronized (session.getId()) { @@ -50,7 +52,7 @@ public abstract class BaseTerminalHandler extends BaseHandler { try { session.sendMessage(byteBuffer); } catch (IOException e) { - DefaultSystemLog.getLog().error("发送消息失败:" + msg, e); + log.error("发送消息失败:" + msg, e); } } } diff --git a/modules/server/src/main/java/io/jpom/socket/handler/DockerCliHandler.java b/modules/server/src/main/java/io/jpom/socket/handler/DockerCliHandler.java index b73a7a8ce..34004061f 100644 --- a/modules/server/src/main/java/io/jpom/socket/handler/DockerCliHandler.java +++ b/modules/server/src/main/java/io/jpom/socket/handler/DockerCliHandler.java @@ -71,7 +71,7 @@ public class DockerCliHandler extends BaseTerminalHandler { handlerItem.startRead(); } catch (Exception e) { // 输出超时日志 @author jzy - DefaultSystemLog.getLog().error("docker 控制台连接超时", e); + log.error("docker 控制台连接超时", e); sendBinary(session, "docker 控制台连接超时"); this.destroy(session); return; @@ -108,7 +108,7 @@ public class DockerCliHandler extends BaseTerminalHandler { this.sendCommand(handlerItem, payload); } catch (Exception e) { sendBinary(session, "Failure:" + e.getMessage()); - DefaultSystemLog.getLog().error("执行命令异常", e); + log.error("执行命令异常", e); } } diff --git a/modules/server/src/main/java/io/jpom/socket/handler/NodeUpdateHandler.java b/modules/server/src/main/java/io/jpom/socket/handler/NodeUpdateHandler.java index 08d7f4dc5..4777c6218 100644 --- a/modules/server/src/main/java/io/jpom/socket/handler/NodeUpdateHandler.java +++ b/modules/server/src/main/java/io/jpom/socket/handler/NodeUpdateHandler.java @@ -51,6 +51,7 @@ import io.jpom.service.system.SystemParametersServer; import io.jpom.socket.BaseProxyHandler; import io.jpom.socket.ConsoleCommandOp; import io.jpom.socket.client.NodeClient; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.WebSocketSession; import java.io.File; @@ -70,6 +71,7 @@ import java.util.concurrent.ConcurrentMap; */ @SystemPermission(superUser = true) @Feature(cls = ClassFeature.UPGRADE_NODE_LIST, method = MethodFeature.EXECUTE) +@Slf4j public class NodeUpdateHandler extends BaseProxyHandler { private final ConcurrentMap clientMap = new ConcurrentHashMap<>(); @@ -121,7 +123,7 @@ public class NodeUpdateHandler extends BaseProxyHandler { NodeClient client = new NodeClient(url, model, session); clientMap.put(model.getId(), client); } catch (Exception e) { - DefaultSystemLog.getLog().error("创建插件端连接失败", e); + log.error("创建插件端连接失败", e); } }); } @@ -207,7 +209,7 @@ public class NodeUpdateHandler extends BaseProxyHandler { ThreadUtil.execute(() -> this.updateNodeItem(ids.getString(finalI), session, agentFileModel, http)); } } catch (Exception e) { - DefaultSystemLog.getLog().error("升级失败", e); + log.error("升级失败", e); } } @@ -236,7 +238,7 @@ public class NodeUpdateHandler extends BaseProxyHandler { } this.sendMsg(callbackRestartMessage.setData("重连失败"), session); } catch (Exception e) { - DefaultSystemLog.getLog().error("升级后重连插件端失败:" + id, e); + log.error("升级后重连插件端失败:" + id, e); this.sendMsg(callbackRestartMessage.setData("重连插件端失败"), session); } } @@ -277,7 +279,7 @@ public class NodeUpdateHandler extends BaseProxyHandler { } this.sendMsg(restartMessage.setData("重连失败"), session); } catch (Exception e) { - DefaultSystemLog.getLog().error("升级后重连插件端失败:" + id, e); + log.error("升级后重连插件端失败:" + id, e); this.sendMsg(restartMessage.setData("重连插件端失败"), session); } } @@ -304,7 +306,7 @@ public class NodeUpdateHandler extends BaseProxyHandler { this.onError(session, "节点连接丢失"); } } catch (Exception e) { - DefaultSystemLog.getLog().error("升级失败:" + id, e); + log.error("升级失败:" + id, e); this.onError(session, "节点升级失败:" + e.getMessage()); } } diff --git a/modules/server/src/main/java/io/jpom/socket/handler/SshHandler.java b/modules/server/src/main/java/io/jpom/socket/handler/SshHandler.java index bc51ccdfb..39e393377 100644 --- a/modules/server/src/main/java/io/jpom/socket/handler/SshHandler.java +++ b/modules/server/src/main/java/io/jpom/socket/handler/SshHandler.java @@ -44,6 +44,7 @@ import io.jpom.permission.MethodFeature; import io.jpom.service.dblog.SshTerminalExecuteLogService; import io.jpom.service.node.ssh.SshService; import io.jpom.service.user.UserBindWorkspaceService; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -64,6 +65,7 @@ import java.util.concurrent.TimeUnit; * @since 2019/8/9 */ @Feature(cls = ClassFeature.SSH_TERMINAL, method = MethodFeature.EXECUTE) +@Slf4j public class SshHandler extends BaseTerminalHandler { private static final ConcurrentHashMap HANDLER_ITEM_CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); @@ -92,7 +94,7 @@ public class SshHandler extends BaseTerminalHandler { handlerItem.startRead(); } catch (Exception e) { // 输出超时日志 @author jzy - DefaultSystemLog.getLog().error("ssh 控制台连接超时", e); + log.error("ssh 控制台连接超时", e); sendBinary(session, "ssh 控制台连接超时"); this.destroy(session); return; @@ -111,17 +113,19 @@ public class SshHandler extends BaseTerminalHandler { return; } String payload = message.getPayload(); - if (JSONValidator.from(payload).getType() == JSONValidator.Type.Object) { - JSONObject jsonObject = JSONObject.parseObject(payload); - String data = jsonObject.getString("data"); - if (StrUtil.equals(data, "jpom-heart")) { - // 心跳消息不转发 - return; - } - if (StrUtil.equals(data, "resize")) { - // 缓存区大小 - handlerItem.resize(jsonObject); - return; + try (JSONValidator from = JSONValidator.from(payload)) { + if (from.getType() == JSONValidator.Type.Object) { + JSONObject jsonObject = JSONObject.parseObject(payload); + String data = jsonObject.getString("data"); + if (StrUtil.equals(data, "jpom-heart")) { + // 心跳消息不转发 + return; + } + if (StrUtil.equals(data, "resize")) { + // 缓存区大小 + handlerItem.resize(jsonObject); + return; + } } } init(); @@ -134,7 +138,7 @@ public class SshHandler extends BaseTerminalHandler { this.sendCommand(handlerItem, payload, userInfo, sshCommandNotLimited); } catch (Exception e) { sendBinary(session, "Failure:" + e.getMessage()); - DefaultSystemLog.getLog().error("执行命令异常", e); + log.error("执行命令异常", e); } } @@ -194,7 +198,7 @@ public class SshHandler extends BaseTerminalHandler { } void startRead() throws JSchException { - this.channel.connect((int) TimeUnit.SECONDS.toMillis(sshItem.timeOut())); + this.channel.connect((int) TimeUnit.SECONDS.toMillis(sshItem.timeout())); ThreadUtil.execute(this); } @@ -273,7 +277,7 @@ public class SshHandler extends BaseTerminalHandler { if (!this.openSession.isConnected()) { return; } - DefaultSystemLog.getLog().error("读取错误", e); + log.error("读取错误", e); SshHandler.this.destroy(this.session); } } diff --git a/modules/server/src/main/java/io/jpom/socket/handler/TomcatHandler.java b/modules/server/src/main/java/io/jpom/socket/handler/TomcatHandler.java index 7ec7823e9..11e6e698a 100644 --- a/modules/server/src/main/java/io/jpom/socket/handler/TomcatHandler.java +++ b/modules/server/src/main/java/io/jpom/socket/handler/TomcatHandler.java @@ -37,6 +37,7 @@ import io.jpom.socket.ProxySession; import io.jpom.socket.ServiceFileTailWatcher; import io.jpom.system.WebAopLog; import io.jpom.util.SocketSessionUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.socket.WebSocketSession; import java.io.File; @@ -50,6 +51,7 @@ import java.util.Map; * @since 2019/4/24 */ @Feature(cls = ClassFeature.TOMCAT, method = MethodFeature.EXECUTE) +@Slf4j public class TomcatHandler extends BaseProxyHandler { public TomcatHandler() { @@ -87,7 +89,7 @@ public class TomcatHandler extends BaseProxyHandler { ServiceFileTailWatcher.addWatcher(file, session); attributes.put("nowFile", file); } catch (Exception io) { - DefaultSystemLog.getLog().error("监听日志变化", io); + log.error("监听日志变化", io); SocketSessionUtil.send(session, io.getMessage()); } } diff --git a/modules/server/src/main/java/io/jpom/system/init/AutoImportLocalNode.java b/modules/server/src/main/java/io/jpom/system/init/AutoImportLocalNode.java index 4fd433fc7..e2eea8217 100644 --- a/modules/server/src/main/java/io/jpom/system/init/AutoImportLocalNode.java +++ b/modules/server/src/main/java/io/jpom/system/init/AutoImportLocalNode.java @@ -42,6 +42,7 @@ import io.jpom.system.ConfigBean; import io.jpom.system.ServerConfigBean; import io.jpom.util.JsonFileUtil; import io.jpom.util.JvmUtil; +import lombok.extern.slf4j.Slf4j; import java.io.File; @@ -52,6 +53,7 @@ import java.io.File; * @since 2019/4/18 */ @PreLoadClass +@Slf4j public class AutoImportLocalNode { private static NodeService nodeService; @@ -84,7 +86,7 @@ public class AutoImportLocalNode { } findPid(mainClassPid.toString()); } catch (Exception e) { - DefaultSystemLog.getLog().error("自动添加本机节点错误", e); + log.error("自动添加本机节点错误", e); } } diff --git a/modules/server/src/main/java/io/jpom/system/init/CheckAuthorizeToken.java b/modules/server/src/main/java/io/jpom/system/init/CheckAuthorizeToken.java index 357d09c92..181cd72ec 100644 --- a/modules/server/src/main/java/io/jpom/system/init/CheckAuthorizeToken.java +++ b/modules/server/src/main/java/io/jpom/system/init/CheckAuthorizeToken.java @@ -29,6 +29,7 @@ import cn.jiangzeyin.common.PreLoadMethod; import io.jpom.system.JpomRuntimeException; import io.jpom.system.ServerExtConfigBean; import io.jpom.util.CheckPassword; +import lombok.extern.slf4j.Slf4j; /** * 验证token 合法性 @@ -37,6 +38,7 @@ import io.jpom.util.CheckPassword; * @since 2019/8/5 */ @PreLoadClass +@Slf4j public class CheckAuthorizeToken { @PreLoadMethod @@ -46,12 +48,12 @@ public class CheckAuthorizeToken { return; } if (authorizeToken.length() < 6) { - DefaultSystemLog.getLog().error("配置的授权token长度小于六位不生效", new JpomRuntimeException("配置的授权token长度小于六位不生效")); + log.error("配置的授权token长度小于六位不生效", new JpomRuntimeException("配置的授权token长度小于六位不生效")); System.exit(-1); } int strength = CheckPassword.checkPasswordStrength(authorizeToken); if (strength != 2) { - DefaultSystemLog.getLog().error("配置的授权token 需要包含数字,字母,符号的组合", new JpomRuntimeException("配置的授权token 需要包含数字,字母,符号的组合")); + log.error("配置的授权token 需要包含数字,字母,符号的组合", new JpomRuntimeException("配置的授权token 需要包含数字,字母,符号的组合")); System.exit(-1); } } diff --git a/modules/server/src/main/java/io/jpom/system/init/CheckMonitor.java b/modules/server/src/main/java/io/jpom/system/init/CheckMonitor.java index 3dc1437b2..e811e9587 100644 --- a/modules/server/src/main/java/io/jpom/system/init/CheckMonitor.java +++ b/modules/server/src/main/java/io/jpom/system/init/CheckMonitor.java @@ -42,6 +42,7 @@ import io.jpom.service.node.NodeService; import io.jpom.service.node.script.NodeScriptExecuteLogServer; import io.jpom.service.node.script.NodeScriptServer; import io.jpom.system.ConfigBean; +import lombok.extern.slf4j.Slf4j; import java.util.Collection; import java.util.List; @@ -54,6 +55,7 @@ import java.util.Map; * @since 2019/7/14 */ @PreLoadClass(value = Integer.MAX_VALUE) +@Slf4j public class CheckMonitor { @PreLoadMethod @@ -71,7 +73,7 @@ public class CheckMonitor { // RemoteVersion.loadRemoteInfo(); } catch (Exception e) { - DefaultSystemLog.getLog().error("系统调度执行出现错误", e); + log.error("系统调度执行出现错误", e); } }); // 拉取 脚本模版日志 @@ -110,10 +112,10 @@ public class CheckMonitor { jsonObject.put("ids", strings); JsonMessage jsonMessage = NodeForward.requestBody(nodeModel, NodeUrl.SCRIPT_DEL_EXEC_LOG, null, jsonObject); if (jsonMessage.getCode() != HttpStatus.HTTP_OK) { - DefaultSystemLog.getLog().error("删除脚本模版执行数据错误:{}", jsonMessage); + log.error("删除脚本模版执行数据错误:{}", jsonMessage); } } catch (Exception e) { - DefaultSystemLog.getLog().error("同步脚本异常", e); + log.error("同步脚本异常", e); } } @@ -130,7 +132,7 @@ public class CheckMonitor { statusRecoverMap.forEach((name, iCron) -> { int count = iCron.statusRecover(); if (count > 0) { - DefaultSystemLog.getLog().debug("{} Recover bad data {}", name, count); + log.debug("{} Recover bad data {}", name, count); } }); // diff --git a/modules/server/src/main/java/io/jpom/system/init/InitDb.java b/modules/server/src/main/java/io/jpom/system/init/InitDb.java index 00ef2f6c6..6c34317dc 100644 --- a/modules/server/src/main/java/io/jpom/system/init/InitDb.java +++ b/modules/server/src/main/java/io/jpom/system/init/InitDb.java @@ -144,7 +144,7 @@ public class InitDb implements DisposableBean, InitializingBean { } sqlFileNow = resource.getFilename(); int rows = Db.use(dsFactory.getDataSource()).execute(sql); - DefaultSystemLog.getLog().info("exec init SQL file: {} complete, and affected rows is: {}", sqlFileNow, rows); + log.info("exec init SQL file: {} complete, and affected rows is: {}", sqlFileNow, rows); executeSqlLog.add(sha1); } catch (IOException ignored) { } @@ -153,7 +153,7 @@ public class InitDb implements DisposableBean, InitializingBean { GlobalDSFactory.set(dsFactory); // } catch (Exception e) { - DefaultSystemLog.getLog().error("初始化数据库失败 {}", sqlFileNow, e); + log.error("初始化数据库失败 {}", sqlFileNow, e); System.exit(0); return; } diff --git a/modules/server/src/main/java/io/jpom/system/init/LoadBuildJsonToDB.java b/modules/server/src/main/java/io/jpom/system/init/LoadBuildJsonToDB.java index e8871eaa9..c271c39eb 100644 --- a/modules/server/src/main/java/io/jpom/system/init/LoadBuildJsonToDB.java +++ b/modules/server/src/main/java/io/jpom/system/init/LoadBuildJsonToDB.java @@ -39,6 +39,7 @@ import io.jpom.service.h2db.TableName; import io.jpom.system.ConfigBean; import io.jpom.system.ServerConfigBean; import io.jpom.util.JsonFileUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.Assert; import java.io.File; @@ -57,6 +58,7 @@ import java.util.stream.Stream; * @author Hotstrip * @since 2021-08-02 */ +@Slf4j public class LoadBuildJsonToDB { private LoadBuildJsonToDB() { @@ -85,7 +87,7 @@ public class LoadBuildJsonToDB { // 判断 list 是否为空 if (null == list) { if (!FileUtil.exist(FileUtil.file(backupOldData, ServerConfigBean.BUILD))) { - //DefaultSystemLog.getLog().warn("There is no any data, the build.json file maybe no content or file is not exist..."); + //log.warn("There is no any data, the build.json file maybe no content or file is not exist..."); } return; } @@ -93,7 +95,7 @@ public class LoadBuildJsonToDB { initSql(list); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } /** @@ -120,7 +122,7 @@ public class LoadBuildJsonToDB { // 遍历对象集合 list.forEach(buildModelVo -> { - DefaultSystemLog.getLog().debug("buildModelVo: {}", JSON.toJSONString(buildModelVo)); + log.debug("buildModelVo: {}", JSON.toJSONString(buildModelVo)); // 拿到构造 SQL 的参数 String gitUrl = buildModelVo.getString("gitUrl"); @@ -171,9 +173,9 @@ public class LoadBuildJsonToDB { try { rows = Db.use(dsFactory.getDataSource()).execute(sql); } catch (SQLException e) { - DefaultSystemLog.getLog().warn("exec SQL: {} failed", sql, e); + log.warn("exec SQL: {} failed", sql, e); } - DefaultSystemLog.getLog().info("exec SQL: {} complete, and affected rows is: {}", sql, rows); + log.info("exec SQL: {} complete, and affected rows is: {}", sql, rows); } /** @@ -243,7 +245,7 @@ public class LoadBuildJsonToDB { */ private List readBuildJsonFileToList(File file) { if (!file.exists()) { - DefaultSystemLog.getLog().debug("there is no build.json file..."); + log.debug("there is no build.json file..."); return null; } try { @@ -254,7 +256,7 @@ public class LoadBuildJsonToDB { .flatMap((Function>) o -> Stream.of((JSONObject) o)) .collect(Collectors.toList()); } catch (FileNotFoundException e) { - DefaultSystemLog.getLog().error("read build.json file failed...caused: {}...message: {}", e.getCause(), e.getMessage()); + log.error("read build.json file failed...caused: {}...message: {}", e.getCause(), e.getMessage()); } return null; } diff --git a/modules/server/src/main/java/io/jpom/system/init/LoadJsonConfigToDb.java b/modules/server/src/main/java/io/jpom/system/init/LoadJsonConfigToDb.java index fad8d70b1..be5f6e39e 100644 --- a/modules/server/src/main/java/io/jpom/system/init/LoadJsonConfigToDb.java +++ b/modules/server/src/main/java/io/jpom/system/init/LoadJsonConfigToDb.java @@ -47,6 +47,7 @@ import io.jpom.service.user.UserService; import io.jpom.system.ConfigBean; import io.jpom.system.ServerConfigBean; import io.jpom.util.JsonFileUtil; +import lombok.extern.slf4j.Slf4j; import java.io.File; import java.util.List; @@ -58,6 +59,7 @@ import java.util.stream.Collectors; * @author bwcx_jzy * @since 2021/12/2 */ +@Slf4j public class LoadJsonConfigToDb { private LoadJsonConfigToDb() { @@ -91,9 +93,9 @@ public class LoadJsonConfigToDb { parametersServer.upsert(SystemIpConfigModel.ID, systemIpConfigModel, SystemIpConfigModel.ID); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load ip config error ", e); + log.error("load ip config error ", e); } } @@ -114,9 +116,9 @@ public class LoadJsonConfigToDb { parametersServer.upsert(MailAccountModel.ID, mailAccountModel, MailAccountModel.ID); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load mail config error ", e); + log.error("load mail config error ", e); } } @@ -138,9 +140,9 @@ public class LoadJsonConfigToDb { parametersServer.upsert(id, serverWhitelist, id); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load mail config error ", e); + log.error("load mail config error ", e); } } @@ -172,9 +174,9 @@ public class LoadJsonConfigToDb { userService.insert(userModels); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load user info error ", e); + log.error("load user info error ", e); } } @@ -201,9 +203,9 @@ public class LoadJsonConfigToDb { nodeService.insert(nodeModels); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load node error ", e); + log.error("load node error ", e); } } @@ -225,9 +227,9 @@ public class LoadJsonConfigToDb { sshService.insert(sshModels); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load ssh error ", e); + log.error("load ssh error ", e); } } @@ -250,9 +252,9 @@ public class LoadJsonConfigToDb { monitorService.insert(monitorModels); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load monitor error ", e); + log.error("load monitor error ", e); } } @@ -276,9 +278,9 @@ public class LoadJsonConfigToDb { outGivingServer.insert(outGivingModels); // 将 json 文件转移到备份目录 FileUtil.move(file, FileUtil.mkdir(backupOldData), true); - DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); + log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData)); } catch (Exception e) { - DefaultSystemLog.getLog().error("load OUTGIVING error ", e); + log.error("load OUTGIVING error ", e); } } diff --git a/modules/server/src/main/java/io/jpom/system/init/OperateLogController.java b/modules/server/src/main/java/io/jpom/system/init/OperateLogController.java index f5503bbf9..210984cc2 100644 --- a/modules/server/src/main/java/io/jpom/system/init/OperateLogController.java +++ b/modules/server/src/main/java/io/jpom/system/init/OperateLogController.java @@ -49,6 +49,7 @@ import io.jpom.service.dblog.DbUserOperateLogService; import io.jpom.system.AopLogInterface; import io.jpom.system.WebAopLog; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.Signature; @@ -70,6 +71,7 @@ import java.util.Set; * @since 2019/4/19 */ @PreLoadClass +@Slf4j public class OperateLogController implements AopLogInterface { private static final ThreadLocal CACHE_INFO_THREAD_LOCAL = new ThreadLocal<>(); @@ -88,14 +90,14 @@ public class OperateLogController implements AopLogInterface { Class declaringClass = method.getDeclaringClass(); MethodFeature methodFeature = feature.method(); if (methodFeature == MethodFeature.NULL) { - DefaultSystemLog.getLog().error("权限分发配置错误:{} {}", declaringClass, method.getName()); + log.error("权限分发配置错误:{} {}", declaringClass, method.getName()); return null; } ClassFeature classFeature = feature.cls(); if (classFeature == ClassFeature.NULL) { Feature feature1 = declaringClass.getAnnotation(Feature.class); if (feature1 == null || feature1.cls() == ClassFeature.NULL) { - DefaultSystemLog.getLog().error("权限分发配置错误:{} {} class not find", declaringClass, method.getName()); + log.error("权限分发配置错误:{} {} class not find", declaringClass, method.getName()); return null; } classFeature = feature1.cls(); diff --git a/modules/server/src/main/java/io/jpom/util/JwtUtil.java b/modules/server/src/main/java/io/jpom/util/JwtUtil.java index ffdb5d6ac..7fa25e25d 100644 --- a/modules/server/src/main/java/io/jpom/util/JwtUtil.java +++ b/modules/server/src/main/java/io/jpom/util/JwtUtil.java @@ -34,6 +34,7 @@ import cn.hutool.jwt.signers.JWTSignerUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.model.data.UserModel; import io.jpom.system.ServerExtConfigBean; +import lombok.extern.slf4j.Slf4j; /** * jwt 工具类 @@ -41,6 +42,7 @@ import io.jpom.system.ServerExtConfigBean; * @author bwcx_jzy * @since 2020/7/25 */ +@Slf4j public class JwtUtil { /** @@ -82,7 +84,7 @@ public class JwtUtil { try { return parseBody(token); } catch (Exception e) { - DefaultSystemLog.getLog().warn("token 解析失败:" + token, e); + log.warn("token 解析失败:" + token, e); return null; } } diff --git a/modules/server/src/test/java/TestJschExec.java b/modules/server/src/test/java/TestJschExec.java index 31121ea2e..38640f8b6 100644 --- a/modules/server/src/test/java/TestJschExec.java +++ b/modules/server/src/test/java/TestJschExec.java @@ -31,6 +31,7 @@ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; +import lombok.extern.slf4j.Slf4j; import org.junit.Test; import java.io.IOException; @@ -45,6 +46,7 @@ import java.util.concurrent.TimeUnit; * @author bwcx_jzy * @since 2021/7/29 */ +@Slf4j public class TestJschExec { //private static final String cmd = "java -Dappliction=jpom-test-jar -jar /home/data/test/springboot-test-jar-0.0.1-SNAPSHOT.jar"; @@ -89,7 +91,7 @@ public class TestJschExec { //System.out.println(s + " " + command.length); } catch (Exception e) { e.printStackTrace(); - DefaultSystemLog.getLog().error("写入错误", e); + log.error("写入错误", e); } } }).addRepeatWorker(() -> { @@ -102,7 +104,7 @@ public class TestJschExec { stringBuilder.append(new String(Arrays.copyOfRange(buffer, 0, i), CharsetUtil.CHARSET_UTF_8)); } } catch (Exception e) { - DefaultSystemLog.getLog().error("读取错误", e); + log.error("读取错误", e); } }).start(); System.out.println(stringBuilder); @@ -136,7 +138,7 @@ public class TestJschExec { } catch (Exception e) { e.printStackTrace(); if (!StrUtil.contains(e.getMessage(), "Pipe closed")) { - DefaultSystemLog.getLog().error("读取 exec err 流发生异常", e); + log.error("读取 exec err 流发生异常", e); error[0] = "读取 exec err 流发生异常" + e.getMessage(); } } finally { @@ -148,7 +150,7 @@ public class TestJschExec { } catch (Exception e) { e.printStackTrace(); if (!StrUtil.contains(e.getMessage(), "Pipe closed")) { - DefaultSystemLog.getLog().error("读取 exec 流发生异常", e); + log.error("读取 exec 流发生异常", e); result[0] = "读取 exec 流发生异常" + e.getMessage(); } } finally { @@ -184,7 +186,7 @@ public class TestJschExec { } catch (Exception e) { e.printStackTrace(); if (!StrUtil.contains(e.getMessage(), "Pipe closed")) { - DefaultSystemLog.getLog().error("读取 exec err 流发生异常", e); + log.error("读取 exec err 流发生异常", e); error[0] = "读取 exec err 流发生异常" + e.getMessage(); } } @@ -194,7 +196,7 @@ public class TestJschExec { } catch (Exception e) { e.printStackTrace(); if (!StrUtil.contains(e.getMessage(), "Pipe closed")) { - DefaultSystemLog.getLog().error("读取 exec 流发生异常", e); + log.error("读取 exec 流发生异常", e); result[0] = "读取 exec 流发生异常" + e.getMessage(); } } @@ -225,7 +227,7 @@ public class TestJschExec { } catch (Exception e) { e.printStackTrace(); if (!StrUtil.contains(e.getMessage(), "Pipe closed")) { - DefaultSystemLog.getLog().error("读取 exec 流发生异常", e); + log.error("读取 exec 流发生异常", e); result = "读取 exec 流发生异常" + e.getMessage(); } } @@ -235,7 +237,7 @@ public class TestJschExec { } catch (Exception e) { e.printStackTrace(); if (!StrUtil.contains(e.getMessage(), "Pipe closed")) { - DefaultSystemLog.getLog().error("读取 exec err 流发生异常", e); + log.error("读取 exec err 流发生异常", e); error = "读取 exec err 流发生异常" + e.getMessage(); } } diff --git a/modules/sub-plugin/db-h2/src/main/java/io/jpom/plugin/DefaultDbH2PluginImpl.java b/modules/sub-plugin/db-h2/src/main/java/io/jpom/plugin/DefaultDbH2PluginImpl.java index 4fc2f24b5..9208e476d 100644 --- a/modules/sub-plugin/db-h2/src/main/java/io/jpom/plugin/DefaultDbH2PluginImpl.java +++ b/modules/sub-plugin/db-h2/src/main/java/io/jpom/plugin/DefaultDbH2PluginImpl.java @@ -29,6 +29,7 @@ import cn.hutool.core.lang.Console; import cn.hutool.core.util.StrUtil; import cn.hutool.db.ds.DSFactory; import cn.jiangzeyin.common.DefaultSystemLog; +import lombok.extern.slf4j.Slf4j; import org.h2.store.FileLister; import org.h2.tools.DeleteDbFiles; import org.h2.tools.Recover; @@ -53,6 +54,7 @@ import java.util.Map; * @since 2022/1/18 */ @PluginConfig(name = "db-h2") +@Slf4j public class DefaultDbH2PluginImpl implements IDefaultPlugin { @Override @@ -160,7 +162,7 @@ public class DefaultDbH2PluginImpl implements IDefaultPlugin { String tableNames = StrUtil.join(StrUtil.COMMA, tableNameList.toArray()); sql = StrUtil.format("{} TABLE {}", sql, tableNames); } - DefaultSystemLog.getLog().debug("backup SQL is: {}", sql); + log.debug("backup SQL is: {}", sql); // 执行 SQL 备份脚本 Shell shell = new Shell(); diff --git a/modules/sub-plugin/email/src/main/java/io/jpom/email/DefaultEmailPluginImpl.java b/modules/sub-plugin/email/src/main/java/io/jpom/email/DefaultEmailPluginImpl.java index 8e8f2dc7a..7a3fc6f37 100644 --- a/modules/sub-plugin/email/src/main/java/io/jpom/email/DefaultEmailPluginImpl.java +++ b/modules/sub-plugin/email/src/main/java/io/jpom/email/DefaultEmailPluginImpl.java @@ -30,6 +30,7 @@ import cn.jiangzeyin.common.DefaultSystemLog; import com.alibaba.fastjson.JSONObject; import io.jpom.plugin.IDefaultPlugin; import io.jpom.plugin.PluginConfig; +import lombok.extern.slf4j.Slf4j; import javax.mail.Session; import javax.mail.Transport; @@ -41,6 +42,7 @@ import java.util.Map; * @since 2021/12/22 */ @PluginConfig(name = "email") +@Slf4j public class DefaultEmailPluginImpl implements IDefaultPlugin { @Override @@ -71,7 +73,7 @@ public class DefaultEmailPluginImpl implements IDefaultPlugin { transport.close(); return true; } catch (Exception e) { - DefaultSystemLog.getLog().warn("检查邮箱信息错误:{}", e.getMessage()); + log.warn("检查邮箱信息错误:{}", e.getMessage()); return false; } } diff --git a/modules/sub-plugin/webhook/src/main/java/io/jpom/webhook/DefaultWebhookPluginImpl.java b/modules/sub-plugin/webhook/src/main/java/io/jpom/webhook/DefaultWebhookPluginImpl.java index 0400b8b76..608ed9c4b 100644 --- a/modules/sub-plugin/webhook/src/main/java/io/jpom/webhook/DefaultWebhookPluginImpl.java +++ b/modules/sub-plugin/webhook/src/main/java/io/jpom/webhook/DefaultWebhookPluginImpl.java @@ -29,6 +29,7 @@ import cn.hutool.http.HttpUtil; import cn.jiangzeyin.common.DefaultSystemLog; import io.jpom.plugin.IDefaultPlugin; import io.jpom.plugin.PluginConfig; +import lombok.extern.slf4j.Slf4j; import java.util.Map; @@ -39,6 +40,7 @@ import java.util.Map; * @since 2021/12/22 */ @PluginConfig(name = "webhook") +@Slf4j public class DefaultWebhookPluginImpl implements IDefaultPlugin { @Override @@ -51,10 +53,10 @@ public class DefaultWebhookPluginImpl implements IDefaultPlugin { HttpRequest httpRequest = HttpUtil.createGet(webhook); httpRequest.form(parameter); String body = httpRequest.execute().body(); - DefaultSystemLog.getLog().info(webhook + CharPool.COLON + body); + log.info(webhook + CharPool.COLON + body); return body; } catch (Exception e) { - DefaultSystemLog.getLog().error("WebHooks 调用错误", e); + log.error("WebHooks 调用错误", e); return "WebHooks error:" + e.getMessage(); } } diff --git a/web-vue/src/api/ssh.js b/web-vue/src/api/ssh.js index d8ed3b273..d0daa92b8 100644 --- a/web-vue/src/api/ssh.js +++ b/web-vue/src/api/ssh.js @@ -59,7 +59,7 @@ export function editSsh(params) { fileDirs: params.fileDirs, notAllowedCommand: params.notAllowedCommand, allowEditSuffix: params.allowEditSuffix, - timeOut: params.timeOut, + timeout: params.timeout, }; return axios({ url: "/node/ssh/save.json", diff --git a/web-vue/src/pages/ssh/ssh.vue b/web-vue/src/pages/ssh/ssh.vue index 4022f024f..9689f7f48 100644 --- a/web-vue/src/pages/ssh/ssh.vue +++ b/web-vue/src/pages/ssh/ssh.vue @@ -178,8 +178,8 @@ - - + + @@ -562,7 +562,7 @@ export default { type: "add", charset: "UTF-8", port: 22, - timeOut: 5, + timeout: 5, connectType: "PASS", }; this.editSshVisible = true; @@ -580,7 +580,7 @@ export default { fileDirs: record.fileDirs ? JSON.parse(record.fileDirs).join("\r\n") : "", type: "edit", allowEditSuffix: record.allowEditSuffix ? JSON.parse(record.allowEditSuffix).join("\r\n") : "", - timeOut: record.timeOut || 5, + timeout: record.timeout || 5, }; this.editSshVisible = true; // @author jzy 08-04