refactor: 完善日志打印

This commit is contained in:
chenjianxing 2020-11-25 10:36:30 +08:00
parent 83daf96f01
commit 754f067cdd
20 changed files with 46 additions and 46 deletions

View File

@ -161,13 +161,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name());
}
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
try {
sendTask(report, testResult);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}

View File

@ -50,7 +50,7 @@ public class JmeterDocumentParser {
}
return documentToBytes(document);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
return source;
}
}

View File

@ -131,7 +131,7 @@ public class APITestService {
file.createNewFile();
FileUtil.copyStream(in, out);
} catch (IOException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(Translator.get("upload_fail"));
}
}
@ -174,7 +174,7 @@ public class APITestService {
try {
FileUtil.copyDir(sourceFile, new File(targetDir));
} catch (IOException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(Translator.get("upload_fail"));
}
}
@ -437,7 +437,7 @@ public class APITestService {
bytes = JmeterDocumentParser.parse(bytes);
is = new ByteArrayInputStream(bytes);
} catch (IOException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
jMeterService.run(request.getId(), reportId, is);

View File

@ -88,7 +88,7 @@ public class CompressUtils {
gzip.finish();
return obj.toByteArray();
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
return data;
}
}
@ -116,7 +116,7 @@ public class CompressUtils {
baos.flush();
return baos.toByteArray();
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
return data;
}
}

View File

@ -18,7 +18,7 @@ public class ScriptEngineUtils {
String script = IOUtils.toString(ScriptEngineUtils.class.getResource("/javascript/func.js"), StandardCharsets.UTF_8);
engine.eval(script);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -26,7 +26,7 @@ public class ScriptEngineUtils {
try {
return engine.eval("calculate('" + input + "')").toString();
} catch (ScriptException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
return input;
}
}

View File

@ -66,7 +66,7 @@ public class DingTaskService {
try {
response = client.execute(request);
} catch (ApiException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
System.out.println(response.getErrcode());
}

View File

@ -65,7 +65,7 @@ public class MailService {
}
sendApiOrLoadNotification(addresseeIdList(messageDetail, userIds, eventType), context, performanceTemplate, loadTestReport.getTriggerMode());
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -86,7 +86,7 @@ public class MailService {
}
sendApiOrLoadNotification(addresseeIdList(messageDetail, userIds, eventType), context, apiTemplate, apiTestReport.getTriggerMode());
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -118,7 +118,7 @@ public class MailService {
try {
javaMailSender.send(mimeMessage);
} catch (MailException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
//测试评审
@ -129,7 +129,7 @@ public class MailService {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewEnd.html"), StandardCharsets.UTF_8);
sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -139,7 +139,7 @@ public class MailService {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewDelete.html"), StandardCharsets.UTF_8);
sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -156,7 +156,7 @@ public class MailService {
String commentTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewComments.html"), StandardCharsets.UTF_8);
sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, commentTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -166,7 +166,7 @@ public class MailService {
String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewInitiate.html"), StandardCharsets.UTF_8);
sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, reviewerTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -205,7 +205,7 @@ public class MailService {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanStart.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -217,7 +217,7 @@ public class MailService {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanEnd.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -229,7 +229,7 @@ public class MailService {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanDelete.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -266,7 +266,7 @@ public class MailService {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/IssuesCreate.html"), StandardCharsets.UTF_8);
sendIssuesNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}

View File

@ -59,7 +59,7 @@ public class WxChatTaskService {
SendResult result = WxChatbotClient.send(Webhook, message);
System.out.println(result);
} catch (IOException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}

View File

@ -139,10 +139,10 @@ public class EngineFactory {
String content = engineSourceParser.parse(engineContext, source);
engineContext.setContent(content);
} catch (MSException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
throw e;
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(e);
}

View File

@ -64,10 +64,10 @@ public class DockerTestEngine extends AbstractEngine {
try {
context = EngineFactory.createContext(loadTest, resource.getId(), ratio, this.getStartTime(), this.getReportId(), resourceIndex);
} catch (MSException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
throw e;
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(e);
}

View File

@ -65,7 +65,7 @@ public class PerformanceNoticeTask {
//查询定时任务是否关闭
Thread.sleep(1000 * 30);// 每分钟检查 loadtest 的状态
} catch (InterruptedException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
});

View File

@ -258,7 +258,7 @@ public class PerformanceTestService {
soc.close();
}
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(Translator.get("load_test_kafka_invalid"));
}
}
@ -304,7 +304,7 @@ public class PerformanceTestService {
} catch (MSException e) {
// 启动失败之后清理任务
engine.stop();
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
loadTest.setStatus(PerformanceTestStatus.Error.name());
loadTest.setDescription(e.getMessage());
loadTestMapper.updateByPrimaryKeySelective(loadTest);

View File

@ -119,7 +119,7 @@ public class JarConfigService {
file.createNewFile();
FileUtil.copyStream(in, out);
} catch (IOException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(Translator.get("upload_fail"));
}
return filePath;

View File

@ -107,7 +107,7 @@ public class SystemParameterService {
try {
javaMailSender.testConnection();
} catch (MessagingException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException(Translator.get("connection_failed"));
}
}

View File

@ -135,7 +135,7 @@ public class TestResourcePoolService {
MSException.throwException("Resource Pool is invalid.");
}
} catch (IllegalAccessException | InvocationTargetException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -161,7 +161,7 @@ public class TestResourcePoolService {
testResourcePoolDTO.setResources(testResources);
testResourcePoolDTOS.add(testResourcePoolDTO);
} catch (IllegalAccessException | InvocationTargetException e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
});
return testResourcePoolDTOS;
@ -210,7 +210,7 @@ public class TestResourcePoolService {
ResponseEntity<String> entity = restTemplateWithTimeOut.getForEntity(String.format(nodeControllerUrl, node.getIp(), node.getPort()), String.class);
return HttpStatus.OK.equals(entity.getStatusCode());
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
return false;
}
}

View File

@ -116,7 +116,7 @@ public class IssuesService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}

View File

@ -84,7 +84,7 @@ public class TestCaseCommentService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}

View File

@ -127,7 +127,7 @@ public class TestCaseReviewService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -205,7 +205,7 @@ public class TestCaseReviewService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -316,7 +316,7 @@ public class TestCaseReviewService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -466,7 +466,7 @@ public class TestCaseReviewService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
}

View File

@ -137,7 +137,7 @@ public class TestPlanService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
@ -188,7 +188,7 @@ public class TestPlanService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
return i;
@ -272,7 +272,7 @@ public class TestPlanService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
return num;
}
@ -513,7 +513,7 @@ public class TestPlanService {
}
});
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}

View File

@ -106,7 +106,7 @@ public class ReportWebSocket {
}
Thread.sleep(20 * 1000L);
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error(e.getMessage(), e);
}
}
}