diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java index 4588d7386..65003e0ec 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java @@ -18,6 +18,7 @@ import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.CmpAroundAspectHolder; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -303,4 +304,12 @@ public abstract class NodeComponent{ public String getChainName(){ return getSlot().getChainName(); } + + public String getDisplayName(){ + if(StringUtils.isEmpty(this.name)){ + return this.nodeId; + }else { + return this.nodeId + "(" + this.name + ")"; + } + } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptComponent.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptComponent.java index 7ceb8572c..9e8aa1405 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptComponent.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptComponent.java @@ -19,7 +19,7 @@ public class ScriptComponent extends NodeComponent{ } public void loadScript(String script) { - log.info("load script for component[{}]", getNodeId()); + log.info("load script for component[{}][{}]", getNodeId(),getDisplayName()); ScriptExecutorFactory.loadInstance().getScriptExecutor().load(getNodeId(), script); } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java index dec157568..88d827442 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java @@ -32,6 +32,7 @@ import com.yomahub.liteflow.spi.holder.ContextAwareHolder; import com.yomahub.liteflow.spi.local.LocalContextAware; import com.yomahub.liteflow.util.CopyOnWriteHashMap; import com.yomahub.liteflow.util.LiteFlowProxyUtil; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -156,7 +157,7 @@ public class FlowBus { nodeMap.put(nodeId, node); } catch (Exception e) { - String error = StrUtil.format("component[{}] register error", cmpClazz.getName()); + String error = StrUtil.format("component[{}][{}] register error", cmpClazz.getName(), StringUtils.isEmpty(name)?nodeId:nodeId+"("+name+")"); LOG.error(error, e); throw new ComponentCannotRegisterException(error); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java index 6fbfebcbd..b5246068d 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java @@ -126,7 +126,7 @@ public class Node implements Executable,Cloneable{ if (instance.isAccess()) { //根据配置判断是否打印执行中的日志 if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())){ - LOG.info("[{}]:[O]start component[{}] [{}] execution",slot.getRequestId(),instance.getClass().getSimpleName(),instance.getName()); + LOG.info("[{}]:[O]start component[{}][{}] execution",slot.getRequestId(),instance.getClass().getSimpleName(),instance.getDisplayName()); } //这里开始进行重试的逻辑和主逻辑的运行 @@ -135,12 +135,12 @@ public class Node implements Executable,Cloneable{ nodeExecutor.execute(instance); //如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束 if (instance.isEnd()) { - String errorInfo = StrUtil.format("[{}]:component[{}] lead the chain to end", slot.getRequestId(), instance.getClass().getSimpleName()); + String errorInfo = StrUtil.format("[{}]:[{}] lead the chain to end", slot.getRequestId(), instance.getClass().getSimpleName(),instance.getDisplayName()); throw new ChainEndException(errorInfo); } } else { if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())){ - LOG.info("[{}]:[X]skip component[{}] execution", slot.getRequestId(), instance.getClass().getSimpleName()); + LOG.info("[{}]:[X]skip component[{}][{}] execution", slot.getRequestId(), instance.getClass().getSimpleName(),instance.getDisplayName()); } } } catch (ChainEndException e){ diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/executor/NodeExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/executor/NodeExecutor.java index 4f863b05a..f8b211cce 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/executor/NodeExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/executor/NodeExecutor.java @@ -50,7 +50,7 @@ public abstract class NodeExecutor { //执行重试逻辑 - 子类通过实现该方法进行重试逻辑的控制 protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { Slot slot = DataBus.getSlot(instance.getSlotIndex()); - LOG.info("[{}]:component[{}] performs {} retry", slot.getRequestId(), instance.getNodeId(), currentRetryCount + 1); + LOG.info("[{}]:component[{}][{}] performs {} retry", slot.getRequestId(), instance.getNodeId(),instance.getDisplayName(), currentRetryCount + 1); //执行业务逻辑的主要入口 instance.execute(); }