Logging
This commit is contained in:
parent
1a9aaeb244
commit
7e724dc4c1
3 changed files with 34 additions and 10 deletions
|
|
@ -2,6 +2,8 @@
|
|||
using LANCommander.Client.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using Photino.Blazor;
|
||||
using Photino.Blazor.CustomWindow.Extensions;
|
||||
using Photino.NET;
|
||||
|
|
@ -27,6 +29,15 @@ namespace LANCommander.Client
|
|||
builder.Services.AddAntDesign();
|
||||
builder.Services.AddDbContext<DbContext, DatabaseContext>();
|
||||
|
||||
NLog.GlobalDiagnosticsContext.Set("StoragePath", settings.Debug.LoggingPath);
|
||||
|
||||
builder.Services.AddLogging(loggingBuilder =>
|
||||
{
|
||||
loggingBuilder.ClearProviders();
|
||||
loggingBuilder.SetMinimumLevel(settings.Debug.LoggingLevel);
|
||||
loggingBuilder.AddNLog();
|
||||
});
|
||||
|
||||
#region Register Client
|
||||
var client = new SDK.Client(settings.Authentication.ServerAddress, settings.Games.DefaultInstallDirectory);
|
||||
|
||||
|
|
|
|||
|
|
@ -172,12 +172,14 @@ namespace LANCommander.Client.Services
|
|||
currentItem.Status = DownloadStatus.InstallingRedistributables;
|
||||
OnQueueChanged?.Invoke();
|
||||
|
||||
Logger?.Trace("Installing redistributables")
|
||||
|
||||
await Task.Run(() => Client.Redistributables.Install(gameInfo));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Download Latest Save
|
||||
// Logger?.Trace("Attempting to download the latest save");
|
||||
Logger?.Trace("Attempting to download the latest save");
|
||||
currentItem.Status = DownloadStatus.DownloadingSaves;
|
||||
OnQueueChanged?.Invoke();
|
||||
|
||||
|
|
@ -197,7 +199,7 @@ namespace LANCommander.Client.Services
|
|||
RunNameChangeScript(gameInfo);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Logger?.Error
|
||||
Logger?.Error(ex, "Scripts failed to execute for mod/expansion {GameTitle} ({GameId})", game.Title, game.Id);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -218,7 +220,7 @@ namespace LANCommander.Client.Services
|
|||
}
|
||||
catch (InstallCanceledException ex)
|
||||
{
|
||||
|
||||
Logger?.Debug("Install canceled");
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -232,7 +234,7 @@ namespace LANCommander.Client.Services
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Logger?.Error(ex, "Scripts failed to run for mod/expansion");
|
||||
Logger?.Error(ex, "Scripts failed to execute for mod/expansion {GameTitle} ({GameId})", dependentGame.Title, dependentGame.Id);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -248,6 +250,8 @@ namespace LANCommander.Client.Services
|
|||
|
||||
await GameService.Update(game);
|
||||
|
||||
Logger?.Trace("Install of game {GameTitle} ({GameId}) complete!", game.Title, game.Id);
|
||||
|
||||
ShowCompletedNotification(currentItem);
|
||||
|
||||
OnInstallComplete?.Invoke();
|
||||
|
|
@ -291,7 +295,7 @@ namespace LANCommander.Client.Services
|
|||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
// Logger?.Trace("Running install script");
|
||||
Logger?.Trace("Running install script for game {GameTitle} ({GameId})", game.Title, game.Id);
|
||||
|
||||
var script = new PowerShellScript();
|
||||
|
||||
|
|
@ -308,6 +312,8 @@ namespace LANCommander.Client.Services
|
|||
return script.Execute();
|
||||
}
|
||||
|
||||
Logger?.Trace("No install script found for game {GameTitle} ({GameId})", game.Title, game.Id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +328,12 @@ namespace LANCommander.Client.Services
|
|||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
// Logger?.Trace("Running name change script");
|
||||
Logger?.Trace("Running name change script for game {GameTitle} ({GameId})", game.Title, game.Id);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(oldName))
|
||||
Logger?.Trace("Old Name: {OldName}", oldName);
|
||||
|
||||
Logger?.Trace("New Name: {NewName}", newName);
|
||||
|
||||
var script = new PowerShellScript();
|
||||
|
||||
|
|
@ -354,12 +365,14 @@ namespace LANCommander.Client.Services
|
|||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
// Logger?.Trace("Running key change script");
|
||||
Logger?.Trace("Running key change script for game {GameTitle} ({GameId})", game.Title, game.Id);
|
||||
|
||||
var script = new PowerShellScript();
|
||||
|
||||
var key = Client.Games.GetAllocatedKey(manifest.Id);
|
||||
|
||||
Logger?.Trace("New key is {Key}", key);
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.Games.DefaultInstallDirectory);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//using NLog;
|
||||
using NLog;
|
||||
|
||||
namespace LANCommander.Client.Services
|
||||
{
|
||||
public abstract class BaseService
|
||||
{
|
||||
//protected readonly Logger Logger;
|
||||
protected readonly Logger Logger;
|
||||
|
||||
protected BaseService()
|
||||
{
|
||||
//Logger = LogManager.GetLogger(GetType().ToString());
|
||||
Logger = LogManager.GetLogger(GetType().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue