Skip to content

Commit 02f2a9f

Browse files
committed
refactor(GameApp): 优化日志标签名称的构建逻辑
移除冗余的ServerType检查,仅保留ServerId和ServerInstanceId作为日志标签 当logTypeParts不为空时,使用下划线连接作为日志标签名称
1 parent edb186f commit 02f2a9f

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

GameFrameX.StartUp/GameApp.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,23 +163,18 @@ public static async Task Entry(string[] args, Action initAction, Action<LogOptio
163163
LogOptions.Default.LogEventLevel = launcherOptions.LogEventLevel;
164164
LogOptions.Default.RollingInterval = launcherOptions.LogRollingInterval;
165165
// 构建LogType,当值为空或默认值时不拼接
166-
// var logTypeParts = new List<string>();
167-
//
168-
// if (!string.IsNullOrWhiteSpace(launcherOptions.ServerType))
169-
// {
170-
// logTypeParts.Add(launcherOptions.ServerType);
171-
// }
172-
//
173-
// if (launcherOptions.ServerId > 0)
174-
// {
175-
// logTypeParts.Add(launcherOptions.ServerId.ToString());
176-
// }
177-
//
178-
// if (launcherOptions.ServerInstanceId > 0)
179-
// {
180-
// logTypeParts.Add(launcherOptions.ServerInstanceId.ToString());
181-
// }
166+
var logTypeParts = new List<string>();
182167

168+
if (launcherOptions.ServerId > 0)
169+
{
170+
logTypeParts.Add(launcherOptions.ServerId.ToString());
171+
}
172+
173+
if (launcherOptions.ServerInstanceId > 0)
174+
{
175+
logTypeParts.Add(launcherOptions.ServerInstanceId.ToString());
176+
}
177+
183178
if (launcherOptions.TagName.IsNotNullOrWhiteSpace())
184179
{
185180
LogOptions.Default.LogTagName = launcherOptions.TagName;
@@ -196,6 +191,8 @@ public static async Task Entry(string[] args, Action initAction, Action<LogOptio
196191
{
197192
LogOptions.Default.LogTagName = launcherOptions.Description;
198193
}
194+
195+
LogOptions.Default.LogTagName = logTypeParts.Count > 0 ? string.Join("_", logTypeParts) : null;
199196
}
200197

201198
logConfiguration?.Invoke(LogOptions.Default);

0 commit comments

Comments
 (0)