mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Improve debugging experience
This commit is contained in:
@@ -35,11 +35,28 @@ namespace ArchiSteamFarm {
|
||||
|
||||
private static readonly ConcurrentHashSet<LoggingRule> ConsoleLoggingRules = new ConcurrentHashSet<LoggingRule>();
|
||||
|
||||
private static bool IsUsingCustomConfiguration;
|
||||
private static bool IsWaitingForUserInput;
|
||||
|
||||
internal static void EnableDebugLogging() {
|
||||
if (IsUsingCustomConfiguration || (LogManager.Configuration == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool reload = false;
|
||||
foreach (LoggingRule rule in LogManager.Configuration.LoggingRules.Where(rule => rule.IsLoggingEnabledForLevel(LogLevel.Debug) && !rule.IsLoggingEnabledForLevel(LogLevel.Trace))) {
|
||||
rule.EnableLoggingForLevel(LogLevel.Trace);
|
||||
reload = true;
|
||||
}
|
||||
|
||||
if (reload) {
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void InitLoggers() {
|
||||
if (LogManager.Configuration != null) {
|
||||
// User provided custom NLog config, or we have it set already, so don't override it
|
||||
IsUsingCustomConfiguration = true;
|
||||
InitConsoleLoggers();
|
||||
LogManager.ConfigurationChanged += OnConfigurationChanged;
|
||||
return;
|
||||
|
||||
@@ -35,6 +35,7 @@ using System.ServiceProcess;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ArchiSteamFarm.Localization;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using SteamKit2;
|
||||
|
||||
@@ -155,6 +156,8 @@ namespace ArchiSteamFarm {
|
||||
|
||||
// If debugging is on, we prepare debug directory prior to running
|
||||
if (GlobalConfig.Debug) {
|
||||
Logging.EnableDebugLogging();
|
||||
|
||||
if (Directory.Exists(SharedInfo.DebugDirectory)) {
|
||||
try {
|
||||
Directory.Delete(SharedInfo.DebugDirectory, true);
|
||||
@@ -329,6 +332,7 @@ namespace ArchiSteamFarm {
|
||||
break;
|
||||
}
|
||||
|
||||
LogManager.Flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -434,7 +438,6 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
ASF.ArchiLogger.LogFatalException((Exception) e.ExceptionObject);
|
||||
await Task.Delay(1000).ConfigureAwait(false); // For writing stuff to logs
|
||||
await Exit(1).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,12 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
Bot.ArchiLogger.LogGenericTrace(Strings.Starting);
|
||||
|
||||
for (byte i = 0; (i < MaxSingleQueuesDaily) && (await IsDiscoveryQueueAvailable().ConfigureAwait(false)).GetValueOrDefault(); i++) {
|
||||
HashSet<uint> queue = await Bot.ArchiWebHandler.GenerateNewDiscoveryQueue().ConfigureAwait(false);
|
||||
if ((queue == null) || (queue.Count == 0)) {
|
||||
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(queue)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -76,6 +79,8 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.DoneClearingDiscoveryQueue, i));
|
||||
}
|
||||
|
||||
Bot.ArchiLogger.LogGenericTrace(Strings.Done);
|
||||
}
|
||||
|
||||
private async Task<bool?> IsDiscoveryQueueAvailable() {
|
||||
@@ -96,6 +101,8 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bot.ArchiLogger.LogGenericTrace(text);
|
||||
|
||||
// It'd make more sense to check against "Come back tomorrow", but it might not cover out-of-the-event queue
|
||||
bool result = text.StartsWith("You can get ", StringComparison.Ordinal);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user