More logging

pull/1805/head
Jamie 7 years ago
parent 7431ed9557
commit be866d3792

@ -67,40 +67,40 @@ namespace Ombi.Schedule.Jobs.Ombi
public async Task Update(PerformContext c) public async Task Update(PerformContext c)
{ {
Ctx = c; Ctx = c;
Ctx.WriteLine("Starting the updater"); Logger.LogInformation("Starting the updater");
var settings = await Settings.GetSettingsAsync(); var settings = await Settings.GetSettingsAsync();
if (!settings.AutoUpdateEnabled) if (!settings.AutoUpdateEnabled)
{ {
Ctx.WriteLine("Auto update is not enabled"); Logger.LogInformation("Auto update is not enabled");
return; return;
} }
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
Ctx.WriteLine("Path: {0}", currentLocation); Logger.LogInformation("Path: {0}", currentLocation);
var productVersion = AssemblyHelper.GetRuntimeVersion(); var productVersion = AssemblyHelper.GetRuntimeVersion();
Logger.LogInformation(LoggingEvents.Updater, "Product Version {0}", productVersion); Logger.LogInformation(LoggingEvents.Updater, "Product Version {0}", productVersion);
Ctx.WriteLine("Product Version {0}", productVersion); Logger.LogInformation("Product Version {0}", productVersion);
try try
{ {
var productArray = GetVersion(); var productArray = GetVersion();
var version = productArray[0]; var version = productArray[0];
Ctx.WriteLine("Version {0}", version); Logger.LogInformation("Version {0}", version);
var branch = productArray[1]; var branch = productArray[1];
Ctx.WriteLine("Branch Version {0}", branch); Logger.LogInformation("Branch Version {0}", branch);
Logger.LogInformation(LoggingEvents.Updater, "Version {0}", version); Logger.LogInformation(LoggingEvents.Updater, "Version {0}", version);
Logger.LogInformation(LoggingEvents.Updater, "Branch {0}", branch); Logger.LogInformation(LoggingEvents.Updater, "Branch {0}", branch);
Ctx.WriteLine("Looking for updates now"); Logger.LogInformation("Looking for updates now");
var updates = await OmbiService.GetUpdates(branch); var updates = await OmbiService.GetUpdates(branch);
Ctx.WriteLine("Updates: {0}", updates); Logger.LogInformation("Updates: {0}", updates);
var serverVersion = updates.UpdateVersionString; var serverVersion = updates.UpdateVersionString;
Logger.LogInformation(LoggingEvents.Updater, "Service Version {0}", updates.UpdateVersionString); Logger.LogInformation(LoggingEvents.Updater, "Service Version {0}", updates.UpdateVersionString);
Ctx.WriteLine("Service Version {0}", updates.UpdateVersionString); Logger.LogInformation("Service Version {0}", updates.UpdateVersionString);
if (!serverVersion.Equals(version, StringComparison.CurrentCultureIgnoreCase)) if (!serverVersion.Equals(version, StringComparison.CurrentCultureIgnoreCase))
{ {
@ -109,7 +109,7 @@ namespace Ombi.Schedule.Jobs.Ombi
var proce = RuntimeInformation.ProcessArchitecture; var proce = RuntimeInformation.ProcessArchitecture;
Logger.LogInformation(LoggingEvents.Updater, "OS Information: {0} {1}", desc, proce); Logger.LogInformation(LoggingEvents.Updater, "OS Information: {0} {1}", desc, proce);
Ctx.WriteLine("OS Information: {0} {1}", desc, proce); Logger.LogInformation("OS Information: {0} {1}", desc, proce);
Download download; Download download;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
@ -128,14 +128,14 @@ namespace Ombi.Schedule.Jobs.Ombi
} }
if (download == null) if (download == null)
{ {
Ctx.WriteLine("There were no downloads"); Logger.LogInformation("There were no downloads");
return; return;
} }
Ctx.WriteLine("Found the download! {0}", download.Name); Logger.LogInformation("Found the download! {0}", download.Name);
Ctx.WriteLine("URL {0}", download.Url); Logger.LogInformation("URL {0}", download.Url);
Ctx.WriteLine("Clearing out Temp Path"); Logger.LogInformation("Clearing out Temp Path");
var tempPath = Path.Combine(currentLocation, "TempUpdate"); var tempPath = Path.Combine(currentLocation, "TempUpdate");
if (Directory.Exists(tempPath)) if (Directory.Exists(tempPath))
{ {
@ -156,7 +156,7 @@ namespace Ombi.Schedule.Jobs.Ombi
Logger.LogInformation(LoggingEvents.Updater, "Downloading the file {0} from {1}", download.Name, download.Url); Logger.LogInformation(LoggingEvents.Updater, "Downloading the file {0} from {1}", download.Name, download.Url);
var extension = download.Name.Split('.').Last(); var extension = download.Name.Split('.').Last();
var zipDir = Path.Combine(currentLocation, $"Ombi.{extension}"); var zipDir = Path.Combine(currentLocation, $"Ombi.{extension}");
Ctx.WriteLine("Zip Dir: {0}", zipDir); Logger.LogInformation("Zip Dir: {0}", zipDir);
try try
{ {
if (File.Exists(zipDir)) if (File.Exists(zipDir))
@ -164,24 +164,24 @@ namespace Ombi.Schedule.Jobs.Ombi
File.Delete(zipDir); File.Delete(zipDir);
} }
Ctx.WriteLine("Starting Download"); Logger.LogInformation("Starting Download");
await DownloadAsync(download.Url, zipDir, c); await DownloadAsync(download.Url, zipDir, c);
Ctx.WriteLine("Finished Download"); Logger.LogInformation("Finished Download");
} }
catch (Exception e) catch (Exception e)
{ {
Ctx.WriteLine("Error when downloading"); Logger.LogInformation("Error when downloading");
Ctx.WriteLine(e.Message); Logger.LogInformation(e.Message);
Logger.LogError(LoggingEvents.Updater, e, "Error when downloading the zip"); Logger.LogError(LoggingEvents.Updater, e, "Error when downloading the zip");
throw; throw;
} }
// Extract it // Extract it
Ctx.WriteLine("Extracting ZIP"); Logger.LogInformation("Extracting ZIP");
Extract(zipDir, tempPath); Extract(zipDir, tempPath);
Ctx.WriteLine("Finished Extracting files"); Logger.LogInformation("Finished Extracting files");
Ctx.WriteLine("Starting the Ombi.Updater process"); Logger.LogInformation("Starting the Ombi.Updater process");
var updaterExtension = string.Empty; var updaterExtension = string.Empty;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
@ -211,12 +211,12 @@ namespace Ombi.Schedule.Jobs.Ombi
{ {
proc.Start(); proc.Start();
} }
Ctx.WriteLine("Bye bye"); Logger.LogInformation("Bye bye");
} }
} }
catch (Exception e) catch (Exception e)
{ {
Ctx.WriteLine(e); Logger.LogError(e, "Exception thrown in the OmbiUpdater, see previous messages");
throw; throw;
} }
} }

Loading…
Cancel
Save