Add more logging to validation

This commit is contained in:
Timothy Baldridge 2021-12-16 15:07:24 -07:00
parent f46348f9b7
commit c1b3b1ddbd

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.Invocation; using System.CommandLine.Invocation;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
@ -268,6 +269,7 @@ public class ValidateLists : IVerb
await patchOutput.DisposeAsync(); await patchOutput.DisposeAsync();
await UploadPatchToCDN(patchFile.Path, $"{upgrade.Hash.ToHex()}_{archive.Hash.ToHex()}", token); await UploadPatchToCDN(patchFile.Path, $"{upgrade.Hash.ToHex()}_{archive.Hash.ToHex()}", token);
_logger.LogInformation("Upgraded {FromHash} to {ToHash}", archive.Hash, upgrade.Hash);
return (ArchiveStatus.Updated, new ValidatedArchive return (ArchiveStatus.Updated, new ValidatedArchive
{ {
Original = archive, Original = archive,
@ -284,21 +286,23 @@ public class ValidateLists : IVerb
try try
{ {
_logger.Log(LogLevel.Information, _logger.Log(LogLevel.Information,
$"Uploading {patchFile.Size().ToFileSizeString()} patch file to CDN {patchName}"); "Uploading {Size} patch file to CDN {Name}", patchFile.Size().ToFileSizeString(), patchName);
using var client = await (await _ftpSiteCredentials.Get())[StorageSpace.Patches].GetClient(_logger); using var client = await (await _ftpSiteCredentials.Get())[StorageSpace.Patches].GetClient(_logger);
await client.UploadFileAsync(patchFile.ToString(), patchName, FtpRemoteExists.Overwrite, token: token); await client.UploadFileAsync(patchFile.ToString(), patchName, FtpRemoteExists.Overwrite, token: token);
_logger.Log(LogLevel.Information,
"Finished uploading {Size} patch file to CDN {Name}", patchFile.Size().ToFileSizeString(), patchName);
return; return;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, $"Error uploading {patchFile} to CDN"); _logger.LogError(ex, "Error uploading {Name} to CDN", patchName);
if (ex.InnerException != null) if (ex.InnerException != null)
_logger.LogError(ex.InnerException, "Inner Exception"); _logger.LogError(ex.InnerException, "Inner Exception");
} }
} }
_logger.Log(LogLevel.Error, $"Couldn't upload {patchFile} to {patchName}"); _logger.Log(LogLevel.Error, "Couldn't upload {File} to {Name}", patchFile, patchName);
} }