update logging #22

Merged
waffle.lord merged 1 commits from impl/better-logging into main 2024-07-09 18:27:04 -04:00
4 changed files with 23 additions and 14 deletions

View File

@ -4,8 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable>
<AssemblyVersion>2.15.3</AssemblyVersion>
<FileVersion>2.15.3</FileVersion>
<AssemblyVersion>2.15.4</AssemblyVersion>
<FileVersion>2.15.4</FileVersion>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />

View File

@ -4,8 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable>
<AssemblyVersion>2.15.3</AssemblyVersion>
<FileVersion>2.15.3</FileVersion>
<AssemblyVersion>2.15.4</AssemblyVersion>
<FileVersion>2.15.4</FileVersion>
</PropertyGroup>
<ItemGroup>
@ -42,8 +42,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\..\..\..\Downloads\PatchClient.exe">
<Link>Resources\PatchClient.exe</Link>
</EmbeddedResource>
<EmbeddedResource Include="Resources\PatchClient.exe" />
</ItemGroup>
</Project>

View File

@ -483,10 +483,10 @@ namespace PatcherUtils
if (sourceFile == null)
{
patchingTokenSource.Cancel();
errorsQueue.Enqueue(new PatchMessage(
$"Failed to find matching source file for '{deltaFile.FullName}'",
PatcherExitCode.MissingFile));
patchingTokenSource.Cancel();
return;
}
@ -495,8 +495,8 @@ namespace PatcherUtils
if (!result.Item1)
{
patchingTokenSource.Cancel();
errorsQueue.Enqueue(new PatchMessage(result.Item2, PatcherExitCode.PatchFailed));
patchingTokenSource.Cancel();
return;
}
@ -520,9 +520,9 @@ namespace PatcherUtils
}
catch (Exception ex)
{
patchingTokenSource.Cancel();
PatchLogger.LogException(ex);
errorsQueue.Enqueue(new PatchMessage(ex.Message, PatcherExitCode.PatchFailed));
patchingTokenSource.Cancel();
return;
}
@ -545,9 +545,9 @@ namespace PatcherUtils
}
catch (Exception ex)
{
patchingTokenSource.Cancel();
PatchLogger.LogException(ex);
errorsQueue.Enqueue(new PatchMessage(ex.Message, PatcherExitCode.PatchFailed));
patchingTokenSource.Cancel();
return;
}
@ -573,12 +573,23 @@ namespace PatcherUtils
if (errorsQueue.Count > 0)
{
PatchLogger.LogError($"Error queue entry count: {errorsQueue.Count}");
if (!errorsQueue.TryDequeue(out PatchMessage error))
PatchLogger.LogError("Dequeuing errors");
PatchMessage error = null;
for (int i = 0; i < errorsQueue.Count; i++)
{
return new PatchMessage("Errors occurred during patching, but we couldn't dequeue them :(\n\nThere may be more information in the log", PatcherExitCode.PatchFailed);
if (!errorsQueue.TryDequeue(out error))
{
return new PatchMessage(
"Errors occurred during patching, but we couldn't dequeue them :(\n\nThere may be more information in the log",
PatcherExitCode.PatchFailed);
}
return error;
PatchLogger.LogError(error.Message);
}
return error ?? new PatchMessage("Something went wrong :(", PatcherExitCode.PatchFailed);
}
PatchLogger.LogInfo("::: Patching Complete :::");