mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Fix logging module corruption on IPC startup failure
Failure of IPC startup currently corrupts ASF logging mechanism, and since ASF expects that logging mechanism to be operative afterwards, it crashes in internal code the moment it requires user input. Fix that, and add additional safety safeguards in case we have a legit lack of logging configuration. https://steamcommunity.com/groups/archiasf/discussions/1/3422187248450123255/
This commit is contained in:
@@ -104,7 +104,7 @@ internal static class ArchiKestrel {
|
||||
}
|
||||
);
|
||||
|
||||
builder.UseNLog();
|
||||
builder.UseNLog(new NLogAspNetCoreOptions { ShutdownOnDispose = false });
|
||||
|
||||
builder.ConfigureWebHostDefaults(
|
||||
webBuilder => {
|
||||
|
||||
@@ -388,6 +388,10 @@ internal static class Logging {
|
||||
private static void InitConsoleLoggers() {
|
||||
ConsoleLoggingRules.Clear();
|
||||
|
||||
if (LogManager.Configuration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (LoggingRule loggingRule in LogManager.Configuration.LoggingRules.Where(static loggingRule => loggingRule.Targets.Any(static target => target is ColoredConsoleTarget or ConsoleTarget))) {
|
||||
ConsoleLoggingRules.Add(loggingRule);
|
||||
}
|
||||
@@ -418,14 +422,14 @@ internal static class Logging {
|
||||
OnUserInputStart();
|
||||
}
|
||||
|
||||
HistoryTarget? historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
|
||||
HistoryTarget? historyTarget = LogManager.Configuration?.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
|
||||
ArchiKestrel.OnNewHistoryTarget(historyTarget);
|
||||
}
|
||||
|
||||
private static void OnUserInputEnd() {
|
||||
IsWaitingForUserInput = false;
|
||||
|
||||
if (ConsoleLoggingRules.Count == 0) {
|
||||
if ((ConsoleLoggingRules.Count == 0) || (LogManager.Configuration == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -444,7 +448,7 @@ internal static class Logging {
|
||||
private static void OnUserInputStart() {
|
||||
IsWaitingForUserInput = true;
|
||||
|
||||
if (ConsoleLoggingRules.Count == 0) {
|
||||
if ((ConsoleLoggingRules.Count == 0) || (LogManager.Configuration == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user