Skip to content

Commit

Permalink
🐳 #376 i18n StatActionInOut
Browse files Browse the repository at this point in the history
  • Loading branch information
iohao committed Oct 5, 2024
1 parent 94bfcb6 commit bd8ca66
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,7 +144,6 @@ public String toString() {
return map.values().stream()
.map(StatAction::toString)
.collect(Collectors.joining("\n"));

}
}

Expand Down Expand Up @@ -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 = "";
Expand All @@ -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
Expand Down Expand Up @@ -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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
}
3 changes: 3 additions & 0 deletions common/common-core/src/main/resources/iohao.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions common/common-core/src/main/resources/iohao_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ debugInOutReturnData=响应
debugInOutErrorCode=错误码
debugInOutErrorMsg=错误信息
debugInOutTime=耗时
# see StatActionInOut.java
statActionInOutTimeRange=%s ms 的请求共 [%d] 个
statActionInOutStatAction=%s, 执行[%s]次, 异常[%s]次, 平均耗时[%d], 最大耗时[%s], 总耗时[%s] %s

0 comments on commit bd8ca66

Please sign in to comment.