Skip to content

Commit a5c1e18

Browse files
committed
refactor: 优化日志信息格式,移除本地化调用
- 将硬编码的本地化字符串替换为直接的英文日志信息,提高可读性和性能 - 在日志中添加更多上下文信息,如方法名、消息类型和组件类型 - 移除对LocalizationService的依赖,简化代码结构
1 parent 5b9a36e commit a5c1e18

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

GameFrameX.Core/BaseHandler/Normal/BaseComponentHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public override async Task<bool> Init(INetworkMessage message, INetWorkChannel n
8989
{
9090
if (ActorId == default)
9191
{
92-
LogHelper.Fatal(LocalizationService.GetString(GameFrameX.Localization.Keys.Core.MessageHandler.ActorIdIsZero, message.GetType().FullName));
92+
LogHelper.Fatal("BaseComponentHandler.Init, ActorId is zero, message type: {messageType}", message.GetType().FullName);
9393
NetWorkChannel.Close();
9494
return false;
9595
}
@@ -100,7 +100,7 @@ public override async Task<bool> Init(INetworkMessage message, INetWorkChannel n
100100
}
101101
catch (Exception e)
102102
{
103-
Log.Fatal(e, "get component failed, close channel");
103+
LogHelper.Fatal(e, "BaseComponentHandler.Init, get component failed, close channel, actorId: {actorId}, componentAgentType: {componentAgentType}", ActorId, ComponentAgentType.FullName);
104104
NetWorkChannel.Close();
105105
return false;
106106
}
@@ -119,7 +119,7 @@ public override Task InnerAction(int timeout = 30000, CancellationToken cancella
119119
{
120120
if (CacheComponent == null)
121121
{
122-
LogHelper.Fatal(LocalizationService.GetString(GameFrameX.Localization.Keys.Core.MessageHandler.CacheComponentIsNull));
122+
LogHelper.Fatal("BaseComponentHandler.InnerAction, CacheComponent is null, message type: {messageType}", Message.GetType().FullName);
123123
NetWorkChannel.Close();
124124
return Task.CompletedTask;
125125
}
@@ -137,7 +137,7 @@ protected Task<TOtherAgent> GetComponentAgent<TOtherAgent>() where TOtherAgent :
137137
{
138138
if (CacheComponent == null)
139139
{
140-
LogHelper.Fatal(LocalizationService.GetString(GameFrameX.Localization.Keys.Core.MessageHandler.CacheComponentIsNull));
140+
LogHelper.Fatal("BaseComponentHandler.GetComponentAgent, CacheComponent is null, message type: {messageType}", Message.GetType().FullName);
141141
NetWorkChannel.Close();
142142
return default;
143143
}

0 commit comments

Comments
 (0)