Commit 3f5d25d1 authored by Spencer Chang's avatar Spencer Chang

[refactor] 调整日志输出

parent c3db8cf6
......@@ -82,8 +82,8 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
public void query4ck(IRequest requestContext, String ip, String dpContext) {
Objects.requireNonNull(dpContext, "传入的语句为空!");
if (logger.isInfoEnabled()) {
logger.info("==============> start execute query4ck");
logger.info("ip:[{}] ==============> 检验查询待执行语句:[{}]", ip, dpContext);
logger.info("==> start execute query4ck");
logger.info("ip:[{}] ==> 检验查询待执行语句:[{}]", ip, dpContext);
}
final String ipWhiteCheck = sysCodeValueMapper.queryCodeValueMeaning("IP_ALLOW_LIST", "IP");
......@@ -127,7 +127,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
sysDpExecuteHistory.setDehError(msg.toString());
self().insertSysDpExecuteHistory(requestContext, sysDpExecuteHistory);
if (logger.isInfoEnabled()) {
logger.info("ip:[{}] ==============> 验证不通过:[{}]", ip, msg.toString());
logger.info("ip:[{}] ==> 验证不通过:[{}]", ip, msg.toString());
}
throw new IllegalArgumentException(msg.toString());
}
......@@ -150,13 +150,13 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
sysDpExecuteHistory.setDehStatus(SqlConstantUtils.SQL_EXEC_DE);
self().insertSysDpExecuteHistory(requestContext, sysDpExecuteHistory);
if (logger.isWarnEnabled()) {
logger.warn("ip:[{}] ==============> 出错:[{}]", ip, e.getMessage());
logger.warn("ip:[{}] ==> 出错:[{}]", ip, e.getMessage());
}
throw new IllegalArgumentException(msg.toString());
}
}
if (logger.isInfoEnabled()) {
logger.info("<============== end execute query4ck");
logger.info("<== end execute query4ck");
}
}
......@@ -172,8 +172,8 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
public void query(IRequest requestContext, HttpServletResponse response, String ip, String dpContext) {
Objects.requireNonNull(dpContext, "传入的语句为空!");
if (logger.isInfoEnabled()) {
logger.info("==============> start execute query");
logger.info("ip:[{}] ==============> 查询待执行语句:[{}]", ip, dpContext);
logger.info("==> start execute query");
logger.info("ip:[{}] ==> 查询待执行语句:[{}]", ip, dpContext);
}
final String ipWhiteCheck = sysCodeValueMapper.queryCodeValueMeaning("IP_ALLOW_LIST", "IP");
SysDpExecuteHistory sysDpExecuteHistory = new SysDpExecuteHistory();
......@@ -267,7 +267,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
ExcelExportUtil excelExportUtil = new ExcelExportUtil();
excelExportUtil.createExcel(response, coumnConfig, retList);
if (logger.isInfoEnabled()) {
logger.info("<============== end execute query");
logger.info("<== end execute query");
}
}
......@@ -283,8 +283,8 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
public ResponseData insert(IRequest requestContext, String ip, String dpContext) {
Objects.requireNonNull(dpContext, "传入的语句为空!");
if (logger.isInfoEnabled()) {
logger.info("==============> start execute insert");
logger.info("ip:[{}] ==============> 新增待执行语句:[{}]", ip, dpContext);
logger.info("==> start execute insert");
logger.info("ip:[{}] ==> 新增待执行语句:[{}]", ip, dpContext);
}
final String ipWhiteCheck = sysCodeValueMapper.queryCodeValueMeaning("IP_ALLOW_LIST", "IP");
ResponseData responseData = new ResponseData(false);
......@@ -342,7 +342,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setSuccess(true);
responseData.setMessage("错误消息:" + e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("ip:[{}] ==============> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
logger.debug("ip:[{}] ==> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
}
return responseData;
}
......@@ -355,14 +355,14 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
sysDpExecuteHistory.setDehStatus(SqlConstantUtils.SQL_EXEC_DE);
responseData.setMessage(e.getMessage());
if (logger.isWarnEnabled()) {
logger.warn("ip:[{}] ==============> 出错:[{}]", ip, e.getMessage());
logger.warn("ip:[{}] ==> 出错:[{}]", ip, e.getMessage());
}
throw new IllegalArgumentException(e.getMessage());
}
}
self().insertSelective(requestContext, sysDpExecuteHistory);
if (logger.isInfoEnabled()) {
logger.info("<============== end execute insert");
logger.info("<== end execute insert");
}
return responseData;
}
......@@ -379,8 +379,8 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
public ResponseData update(IRequest requestContext, String ip, String dpContext) {
Objects.requireNonNull(dpContext, "传入的语句为空!");
if (logger.isInfoEnabled()) {
logger.info("==============> start execute update");
logger.info("ip:[{}] ==============> 更新待执行语句:[{}]", ip, dpContext);
logger.info("==> start execute update");
logger.info("ip:[{}] ==> 更新待执行语句:[{}]", ip, dpContext);
}
final String ipWhiteCheck = sysCodeValueMapper.queryCodeValueMeaning("IP_ALLOW_LIST", "IP");
ResponseData responseData = new ResponseData(false);
......@@ -438,7 +438,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
rowCount = rs.getInt("TOTALCOUNT");
}
if (logger.isInfoEnabled()) {
logger.info("==============> 执行sql[{}],本次更新条件查询:[{}]条数据。", sql, rowCount);
logger.info("==> 执行sql[{}],本次更新条件查询:[{}]条数据。", sql, rowCount);
}
} catch (SQLException e) {
updateDpExecuteHistory.setDehExecuteTime(new Date());
......@@ -449,7 +449,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setSuccess(true);
responseData.setMessage("错误消息:" + e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("ip:[{}] ==============> 执行语句:[{}];出错:[{}]", ip, sql, e.getMessage());
logger.debug("ip:[{}] ==> 执行语句:[{}];出错:[{}]", ip, sql, e.getMessage());
}
return responseData;
}
......@@ -472,7 +472,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
try (PreparedStatement preparedStatement = conn.prepareStatement(dpContext)) {
int updateRowCount = preparedStatement.executeUpdate();
if (logger.isInfoEnabled()) {
logger.info("==============> 执行sql[{}],本次更新:[{}]条数据。", dpContext, updateRowCount);
logger.info("==> 执行sql[{}],本次更新:[{}]条数据。", dpContext, updateRowCount);
}
updateDpExecuteHistory.setDehExecuteTime(new Date());
......@@ -506,7 +506,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setSuccess(true);
responseData.setMessage("错误消息:" + e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("ip:[{}] ==============> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
logger.debug("ip:[{}] ==> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
}
return responseData;
}
......@@ -520,14 +520,14 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setMessage(e.getMessage());
self().insertSysDpExecuteHistory(requestContext, sysDpExecuteHistory);
if (logger.isWarnEnabled()) {
logger.warn("ip:[{}] ==============> 出错:[{}]", ip, e.getMessage());
logger.warn("ip:[{}] ==> 出错:[{}]", ip, e.getMessage());
}
throw new IllegalArgumentException(e.getMessage());
}
}
self().insertSelective(requestContext, sysDpExecuteHistory);
if (logger.isInfoEnabled()) {
logger.info("<============== end execute update");
logger.info("<== end execute update");
}
return responseData;
}
......@@ -544,8 +544,8 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
public ResponseData delete(IRequest requestContext, String ip, String dpContext) {
Objects.requireNonNull(dpContext, "传入的语句为空!");
if (logger.isInfoEnabled()) {
logger.info("==============> start execute delete");
logger.info("ip:[{}] ==============> 删除待执行语句:[{}]", ip, dpContext);
logger.info("==> start execute delete");
logger.info("ip:[{}] ==> 删除待执行语句:[{}]", ip, dpContext);
}
final String ipWhiteCheck = sysCodeValueMapper.queryCodeValueMeaning("IP_ALLOW_LIST", "IP");
ResponseData responseData = new ResponseData(false);
......@@ -598,7 +598,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
rowCount = rs.getInt("TOTALCOUNT");
}
if (logger.isInfoEnabled()) {
logger.info("==============> 执行sql[{}],本次删除前条件查询:[{}]条数据。", sql, rowCount);
logger.info("==> 执行sql[{}],本次删除前条件查询:[{}]条数据。", sql, rowCount);
}
} catch (SQLException e) {
sysDpExecuteHistory.setDehExecuteTime(new Date());
......@@ -609,7 +609,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setSuccess(true);
responseData.setMessage("错误消息:" + e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("ip:[{}] ==============> 执行语句:[{}];出错:[{}]", ip, sql, e.getMessage());
logger.debug("ip:[{}] ==> 执行语句:[{}];出错:[{}]", ip, sql, e.getMessage());
}
return responseData;
}
......@@ -627,7 +627,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
try (PreparedStatement preparedStatement = conn.prepareStatement(dpContext)) {
int deleteRowCount = preparedStatement.executeUpdate();
if (logger.isInfoEnabled()) {
logger.info("==============> 执行sql[{}],本次删除:[{}]条数据。", dpContext, deleteRowCount);
logger.info("==> 执行sql[{}],本次删除:[{}]条数据。", dpContext, deleteRowCount);
}
delDpExecuteHistory.setDehExecuteTime(new Date());
......@@ -661,7 +661,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setSuccess(true);
responseData.setMessage("错误消息:" + e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("ip:[{}] ==============> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
logger.debug("ip:[{}] ==> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
}
return responseData;
}
......@@ -673,14 +673,14 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
sysDpExecuteHistory.setDehStatus(SqlConstantUtils.SQL_EXEC_DE);
self().insertSysDpExecuteHistory(requestContext, sysDpExecuteHistory);
if (logger.isWarnEnabled()) {
logger.warn("ip:[{}] ==============> 出错:[{}]", ip, e.getMessage());
logger.warn("ip:[{}] ==> 出错:[{}]", ip, e.getMessage());
}
throw new IllegalArgumentException(e.getMessage());
}
}
self().insertSelective(requestContext, sysDpExecuteHistory);
if (logger.isInfoEnabled()) {
logger.info("<============== end execute delete");
logger.info("<== end execute delete");
}
return responseData;
}
......@@ -697,8 +697,8 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
public ResponseData ddl(IRequest requestContext, String ip, String dpContext) {
Objects.requireNonNull(dpContext, "传入的语句为空!");
if (logger.isInfoEnabled()) {
logger.info("==============> start execute ddl");
logger.info("ip:[{}] ==============> 待执行DDL语句:[{}]", ip, dpContext);
logger.info("==> start execute ddl");
logger.info("ip:[{}] ==> 待执行DDL语句:[{}]", ip, dpContext);
}
final String ipWhiteCheck = sysCodeValueMapper.queryCodeValueMeaning("IP_ALLOW_LIST", "IP");
ResponseData responseData = new ResponseData(false);
......@@ -751,7 +751,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
responseData.setSuccess(true);
responseData.setMessage("错误消息:" + e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("ip:[{}] ==============> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
logger.debug("ip:[{}] ==> 执行语句:[{}];出错:[{}]", ip, dpContext, e.getMessage());
}
return responseData;
}
......@@ -766,14 +766,14 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
sysDpExecuteHistory.setDehStatus(SqlConstantUtils.SQL_EXEC_DE);
self().insertSysDpExecuteHistory(requestContext, sysDpExecuteHistory);
if (logger.isWarnEnabled()) {
logger.warn("ip:[{}] ==============> 出错:[{}]", ip, e.getMessage());
logger.warn("ip:[{}] ==> 出错:[{}]", ip, e.getMessage());
}
throw new IllegalArgumentException(e.getMessage());
}
}
self().insertSelective(requestContext, sysDpExecuteHistory);
if (logger.isInfoEnabled()) {
logger.info("<============== end execute ddl");
logger.info("<== end execute ddl");
}
return responseData;
}
......@@ -794,7 +794,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
bakData = convertToJson(bakRs);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("==============> 执行备份语句:[{}];出错:[{}]", bakSql, e.getMessage());
logger.debug("==> 执行备份语句:[{}];出错:[{}]", bakSql, e.getMessage());
}
}
bakQuery.close();
......@@ -958,9 +958,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
Future<?> future = taskExecutor.submit(new SubThreadTask(self(), requestContext, ip, formatSql, SqlConstantUtils.SQL_EXEC_INSERT, length, atomicInteger, i, retMsg));
while (true) {
if (future.isDone()) {
retMsg.forEach((k, v) -> {
result.add("第" + k + "行语句," + v);
});
retMsg.forEach((k, v) -> result.add("第" + k + "行语句," + v));
retMsg.clear();
break;
}
......@@ -974,9 +972,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
Future<?> future = taskExecutor.submit(new SubThreadTask(self(), requestContext, ip, formatSql, SqlConstantUtils.SQL_EXEC_UPDATE, length, atomicInteger, i, retMsg));
while (true) {
if (future.isDone()) {
retMsg.forEach((k, v) -> {
result.add("第" + k + "行语句," + v);
});
retMsg.forEach((k, v) -> result.add("第" + k + "行语句," + v));
retMsg.clear();
break;
}
......@@ -990,9 +986,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
Future<?> future = taskExecutor.submit(new SubThreadTask(self(), requestContext, ip, formatSql, SqlConstantUtils.SQL_EXEC_DELETE, length, atomicInteger, i, retMsg));
while (true) {
if (future.isDone()) {
retMsg.forEach((k, v) -> {
result.add("第" + k + "行语句," + v);
});
retMsg.forEach((k, v) -> result.add("第" + k + "行语句," + v));
retMsg.clear();
break;
}
......@@ -1013,9 +1007,7 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
Future<?> future = taskExecutor.submit(new SubThreadTask(self(), requestContext, ip, formatSql, SqlConstantUtils.SQL_EXEC_DDL, length, atomicInteger, i, retMsg));
while (true) {
if (future.isDone()) {
retMsg.forEach((k, v) -> {
result.add("第" + k + "行语句," + v);
});
retMsg.forEach((k, v) -> result.add("第" + k + "行语句," + v));
retMsg.clear();
break;
}
......@@ -1071,16 +1063,15 @@ public class SysDpExecuteHistoryServiceImpl extends BaseServiceImpl<SysDpExecute
} else if (StringUtils.equals(execType, SqlConstantUtils.SQL_EXEC_DDL)) {
responseData = service.ddl(requestContext, ip, sql);
}
logger.info("=========> [{}]-->第[{}]次执行:[{}]", threadName, index, sql);
logger.info("==> [{}]-->第[{}]次执行:[{}]", threadName, index, sql);
retMsg.put(seq, responseData.getMessage());
logger.info("=========> 执行语句[{}]出错,详细信息:[{}]", sql, responseData.getMessage());
logger.info("==> 执行语句[{}],详细信息:[{}]", sql, responseData.getMessage());
if (index == count - 1 || count == 1) {
logger.info("<========= ALL DONE");
logger.info("<== ALL DONE");
}
} catch (Exception e) {
retMsg.put(seq, e.getMessage());
logger.info("=========> 执行语句[{}]出错,详细信息:[{}]", sql, e.getMessage());
logger.info("==> 执行语句[{}]出错,详细信息:[{}]", sql, e.getMessage());
} finally {
mainLock.unlock();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment