From bd8ca66d3e6b06b740b2d9fc00483ce1f9e240b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=94=E6=B0=91=E5=B0=8F=E9=95=87?= <262610965@qq.com> Date: Sat, 5 Oct 2024 07:48:20 +0800 Subject: [PATCH] :whale: #376 i18n StatActionInOut --- .../core/flow/internal/StatActionInOut.java | 13 ++++++++++--- .../iohao/game/action/skeleton/i18n/MessageKey.java | 6 ++++++ .../common-core/src/main/resources/iohao.properties | 3 +++ .../src/main/resources/iohao_zh_CN.properties | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/StatActionInOut.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/StatActionInOut.java index a6a8c09eb..d2ea0f33f 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/StatActionInOut.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/StatActionInOut.java @@ -22,6 +22,8 @@ import com.iohao.game.action.skeleton.core.CmdKit; import com.iohao.game.action.skeleton.core.flow.ActionMethodInOut; import com.iohao.game.action.skeleton.core.flow.FlowContext; +import com.iohao.game.action.skeleton.i18n.Bundle; +import com.iohao.game.action.skeleton.i18n.MessageKey; import com.iohao.game.common.kit.CollKit; import com.iohao.game.common.kit.MoreKit; import com.iohao.game.common.kit.exception.ThrowKit; @@ -142,7 +144,6 @@ public String toString() { return map.values().stream() .map(StatAction::toString) .collect(Collectors.joining("\n")); - } } @@ -225,6 +226,9 @@ public long getAvgTime() { return this.totalTime.sum() / this.executeCount.sum(); } + /** %s, 执行[%s]次, 异常[%s]次, 平均耗时[%d], 最大耗时[%s], 总耗时[%s] %s */ + private final String statActionInOutToString = Bundle.getMessage(MessageKey.statActionInOutStatAction); + @Override public String toString() { String rangeStr = ""; @@ -241,7 +245,7 @@ public String toString() { rangeStr = builder.toString(); } - return String.format("%s, 执行[%s]次, 异常[%s]次, 平均耗时[%d], 最大耗时[%s], 总耗时[%s] %s" + return String.format(statActionInOutToString , CmdKit.toString(this.cmdInfo.getCmdMerge()) , this.executeCount , this.errorCount @@ -382,9 +386,12 @@ void increment() { this.count.increment(); } + /** %s ms 的请求共 [%d] 个 */ + private static final String statActionInOutTimeRange = Bundle.getMessage(MessageKey.statActionInOutTimeRange); + @Override public String toString() { - return String.format("%s ms 的请求共 [%d] 个", this.name, this.count.sum()); + return String.format(statActionInOutTimeRange, this.name, this.count.sum()); } } } diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java index 0904e067f..c1e1c9877 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java @@ -19,6 +19,8 @@ package com.iohao.game.action.skeleton.i18n; /** + * i18n message key, see iohao.properties + * * @author 渔民小镇 * @date 2024-10-02 * @since 21.18 @@ -53,4 +55,8 @@ public interface MessageKey { String debugInOutErrorCode = "debugInOutErrorCode"; String debugInOutErrorMsg = "debugInOutErrorMsg"; String debugInOutTime = "debugInOutTime"; + + /* see StatActionInOut.java */ + String statActionInOutTimeRange = "statActionInOutTimeRange"; + String statActionInOutStatAction = "statActionInOutStatAction"; } diff --git a/common/common-core/src/main/resources/iohao.properties b/common/common-core/src/main/resources/iohao.properties index a01d2fba3..675ce89a0 100644 --- a/common/common-core/src/main/resources/iohao.properties +++ b/common/common-core/src/main/resources/iohao.properties @@ -26,3 +26,6 @@ debugInOutReturnData=ResponseData debugInOutErrorCode=ErrorCode debugInOutErrorMsg=ErrorMsg debugInOutTime=ExecutionTime +# see StatActionInOut.java +statActionInOutTimeRange=%s ms, execute[%d] +statActionInOutStatAction=%s, execute[%s], error[%s], avgTime[%d], maxExecuteTime[%s], totalExecuteTime[%s] %s diff --git a/common/common-core/src/main/resources/iohao_zh_CN.properties b/common/common-core/src/main/resources/iohao_zh_CN.properties index 5a04d3f20..7e44841c7 100644 --- a/common/common-core/src/main/resources/iohao_zh_CN.properties +++ b/common/common-core/src/main/resources/iohao_zh_CN.properties @@ -26,3 +26,6 @@ debugInOutReturnData=响应 debugInOutErrorCode=错误码 debugInOutErrorMsg=错误信息 debugInOutTime=耗时 +# see StatActionInOut.java +statActionInOutTimeRange=%s ms 的请求共 [%d] 个 +statActionInOutStatAction=%s, 执行[%s]次, 异常[%s]次, 平均耗时[%d], 最大耗时[%s], 总耗时[%s] %s