LOG类统一化打印的代码优化

This commit is contained in:
everywhere.z
2024-12-02 12:14:33 +08:00
parent d8bff131ac
commit b8b1cc0048
3 changed files with 6 additions and 18 deletions

View File

@@ -478,20 +478,10 @@ public class FlowExecutor {
catch (Exception e) {
if (ObjectUtil.isNotNull(chain)) {
String errMsg = StrUtil.format("chain[{}] execute error on slot[{}]", chain.getChainId(), slotIndex);
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
LOG.error(errMsg, e);
}
else {
LOG.error(errMsg);
}
LOG.error(errMsg, e);
}
else {
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
LOG.error(e.getMessage(), e);
}
else {
LOG.error(e.getMessage());
}
LOG.error(e.getMessage(), e);
}
// 如果是正常流程需要把异常设置到slot的exception属性里

View File

@@ -373,6 +373,8 @@ public class LFLog implements Logger{
public void error(String s, Throwable throwable) {
if (isPrint()) {
this.log.error(getRId() + s, throwable);
}else{
this.log.error(getRId() + s);
}
}

View File

@@ -382,9 +382,7 @@ public class Slot {
if (ObjectUtil.isNull(this.executeStepsStr)) {
this.executeStepsStr = getExecuteStepStr(true);
}
if (LiteflowConfigGetter.get().getPrintExecutionLog()) {
LOG.info("CHAIN_NAME[{}]\n{}", this.getChainName(), this.executeStepsStr);
}
LOG.info("CHAIN_NAME[{}]\n{}", this.getChainName(), this.executeStepsStr);
}
public void addRollbackStep(CmpStep step) {
@@ -418,9 +416,7 @@ public class Slot {
if (ObjectUtil.isNull(this.rollbackStepsStr)) {
this.rollbackStepsStr = getRollbackStepStr(true);
}
if (LiteflowConfigGetter.get().getPrintExecutionLog()) {
LOG.info("ROLLBACK_CHAIN_NAME[{}]\n{}", this.getChainName(), this.rollbackStepsStr);
}
LOG.info("ROLLBACK_CHAIN_NAME[{}]\n{}", this.getChainName(), this.rollbackStepsStr);
}