mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-13 06:30:43 -05:00
Merge pull request 'added more logging' (!40) from waffle.lord/Launcher:380-more-logging into 3.8.0
Reviewed-on: SPT-AKI/Launcher#40
This commit is contained in:
commit
b6e8d50865
@ -8,11 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
using Aki.Launcher.Helpers;
|
using Aki.Launcher.Helpers;
|
||||||
using Aki.Launcher.MiniCommon;
|
using Aki.Launcher.MiniCommon;
|
||||||
using Aki.Launcher.Models.Aki;
|
using Aki.Launcher.Models.Aki;
|
||||||
using Aki.Launcher.Models.Launcher;
|
using Aki.Launcher.Models.Launcher;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Aki.Launcher.Controllers;
|
||||||
|
|
||||||
namespace Aki.Launcher
|
namespace Aki.Launcher
|
||||||
{
|
{
|
||||||
@ -136,6 +138,8 @@ namespace Aki.Launcher
|
|||||||
return AccountStatus.NoConnection;
|
return AccountStatus.NoConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogManager.Instance.Info($"Account Registered: {username}");
|
||||||
|
|
||||||
return Login(username, password);
|
return Login(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,15 +164,19 @@ namespace Aki.Launcher
|
|||||||
{
|
{
|
||||||
SelectedAccount = null;
|
SelectedAccount = null;
|
||||||
|
|
||||||
|
LogManager.Instance.Info($"Account Removed: {data.username}");
|
||||||
|
|
||||||
return AccountStatus.OK;
|
return AccountStatus.OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Error($"Failed to remove account: {data.username}");
|
||||||
return AccountStatus.UpdateFailed;
|
return AccountStatus.UpdateFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Error($"Failed to remove account: {data.username} - NO CONNECTION");
|
||||||
return AccountStatus.NoConnection;
|
return AccountStatus.NoConnection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,15 +279,18 @@ namespace Aki.Launcher
|
|||||||
|
|
||||||
if (json != STATUS_OK)
|
if (json != STATUS_OK)
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Error($"Failed to wipe account: {data.username}");
|
||||||
return AccountStatus.UpdateFailed;
|
return AccountStatus.UpdateFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Error($"Failed to wipe account: {data.username} - NO CONNECTION");
|
||||||
return AccountStatus.NoConnection;
|
return AccountStatus.NoConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectedAccount.edition = edition;
|
SelectedAccount.edition = edition;
|
||||||
|
LogManager.Instance.Info($"Account Wiped: {data.username} -> {edition}");
|
||||||
return AccountStatus.OK;
|
return AccountStatus.OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,23 +57,32 @@ namespace Aki.Launcher
|
|||||||
|
|
||||||
public async Task<GameStarterResult> LaunchGame(ServerInfo server, AccountInfo account, string gamePath)
|
public async Task<GameStarterResult> LaunchGame(ServerInfo server, AccountInfo account, string gamePath)
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Info(">>> Launching Game");
|
||||||
|
LogManager.Instance.Info($">>> Account: {account.username}");
|
||||||
|
LogManager.Instance.Info($">>> Server : {server.backendUrl}");
|
||||||
// setup directories
|
// setup directories
|
||||||
if (IsInstalledInLive())
|
if (IsInstalledInLive())
|
||||||
{
|
{
|
||||||
LogManager.Instance.Warning("Failed installed in live check");
|
LogManager.Instance.Error("[LaunchGame] Installed in Live :: YES");
|
||||||
return GameStarterResult.FromError(-1);
|
return GameStarterResult.FromError(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Installed in Live :: NO");
|
||||||
|
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Setup Game Files ...");
|
||||||
SetupGameFiles(gamePath);
|
SetupGameFiles(gamePath);
|
||||||
|
|
||||||
if (!ValidationUtil.Validate())
|
if (!ValidationUtil.Validate())
|
||||||
{
|
{
|
||||||
LogManager.Instance.Warning("Failed validation check");
|
LogManager.Instance.Error("[LaunchGame] Game Validation :: FAILED");
|
||||||
return GameStarterResult.FromError(-2);
|
return GameStarterResult.FromError(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Game Validation :: OK");
|
||||||
|
|
||||||
if (account.wipe)
|
if (account.wipe)
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Wipe profile requested");
|
||||||
RemoveRegistryKeys();
|
RemoveRegistryKeys();
|
||||||
CleanTempFiles();
|
CleanTempFiles();
|
||||||
}
|
}
|
||||||
@ -83,10 +92,13 @@ namespace Aki.Launcher
|
|||||||
|
|
||||||
if (!File.Exists(clientExecutable))
|
if (!File.Exists(clientExecutable))
|
||||||
{
|
{
|
||||||
LogManager.Instance.Warning($"Could not find {clientExecutable}");
|
LogManager.Instance.Error("[LaunchGame] Valid Game Path :: FAILED");
|
||||||
|
LogManager.Instance.Error($"Could not find {clientExecutable}");
|
||||||
return GameStarterResult.FromError(-6);
|
return GameStarterResult.FromError(-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Valid Game Path :: OK");
|
||||||
|
|
||||||
// apply patches
|
// apply patches
|
||||||
ProgressReportingPatchRunner patchRunner = new ProgressReportingPatchRunner(gamePath);
|
ProgressReportingPatchRunner patchRunner = new ProgressReportingPatchRunner(gamePath);
|
||||||
|
|
||||||
@ -96,10 +108,12 @@ namespace Aki.Launcher
|
|||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch (TaskCanceledException)
|
||||||
{
|
{
|
||||||
LogManager.Instance.Warning("Failed to apply assembly patch");
|
LogManager.Instance.Error("[LaunchGame] Applying Patch :: FAILED");
|
||||||
return GameStarterResult.FromError(-4);
|
return GameStarterResult.FromError(-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Applying Patch :: OK");
|
||||||
|
|
||||||
//start game
|
//start game
|
||||||
var args =
|
var args =
|
||||||
$"-force-gfx-jobs native -token={account.id} -config={Json.Serialize(new ClientConfig(server.backendUrl))}";
|
$"-force-gfx-jobs native -token={account.id} -config={Json.Serialize(new ClientConfig(server.backendUrl))}";
|
||||||
@ -107,6 +121,7 @@ namespace Aki.Launcher
|
|||||||
if (_showOnly)
|
if (_showOnly)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{clientExecutable} {args}");
|
Console.WriteLine($"{clientExecutable} {args}");
|
||||||
|
LogManager.Instance.Info("[LaunchGame] NOOP :: show only");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -118,6 +133,7 @@ namespace Aki.Launcher
|
|||||||
};
|
};
|
||||||
|
|
||||||
Process.Start(clientProcess);
|
Process.Start(clientProcess);
|
||||||
|
LogManager.Instance.Info("[LaunchGame] Game process started");
|
||||||
}
|
}
|
||||||
|
|
||||||
return GameStarterResult.FromSuccess();
|
return GameStarterResult.FromSuccess();
|
||||||
@ -160,6 +176,7 @@ namespace Aki.Launcher
|
|||||||
if (File.Exists(file.FullName))
|
if (File.Exists(file.FullName))
|
||||||
{
|
{
|
||||||
File.Delete(file.FullName);
|
File.Delete(file.FullName);
|
||||||
|
LogManager.Instance.Warning($"File removed :: found in live dir: {file.FullName}");
|
||||||
isInstalledInLive = true;
|
isInstalledInLive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,6 +186,7 @@ namespace Aki.Launcher
|
|||||||
if (Directory.Exists(directory.FullName))
|
if (Directory.Exists(directory.FullName))
|
||||||
{
|
{
|
||||||
RemoveFilesRecurse(directory);
|
RemoveFilesRecurse(directory);
|
||||||
|
LogManager.Instance.Warning($"Directory removed :: found in live dir: {directory.FullName}");
|
||||||
isInstalledInLive = true;
|
isInstalledInLive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,6 +255,7 @@ namespace Aki.Launcher
|
|||||||
foreach (var value in key.GetValueNames())
|
foreach (var value in key.GetValueNames())
|
||||||
{
|
{
|
||||||
key.DeleteValue(value);
|
key.DeleteValue(value);
|
||||||
|
LogManager.Instance.Debug($"Removing reg key: {key.Name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -266,6 +285,8 @@ namespace Aki.Launcher
|
|||||||
|
|
||||||
bool RemoveFilesRecurse(DirectoryInfo basedir)
|
bool RemoveFilesRecurse(DirectoryInfo basedir)
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Info($"Recursive Removal: {basedir}");
|
||||||
|
|
||||||
if (!basedir.Exists)
|
if (!basedir.Exists)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -286,6 +307,7 @@ namespace Aki.Launcher
|
|||||||
{
|
{
|
||||||
file.IsReadOnly = false;
|
file.IsReadOnly = false;
|
||||||
file.Delete();
|
file.Delete();
|
||||||
|
LogManager.Instance.Debug($" -> del file: {file.FullName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove directory
|
// remove directory
|
||||||
|
@ -17,35 +17,42 @@ namespace Aki.Launcher.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class LogManager
|
public class LogManager
|
||||||
{
|
{
|
||||||
//TODO - update this to use reflection to get the calling method, class, etc
|
|
||||||
private static LogManager _instance;
|
private static LogManager _instance;
|
||||||
public static LogManager Instance => _instance ?? (_instance = new LogManager());
|
public static LogManager Instance => _instance ??= new LogManager();
|
||||||
private string filepath;
|
private readonly string _filePath;
|
||||||
|
private readonly string _logFile;
|
||||||
|
|
||||||
public LogManager()
|
private LogManager()
|
||||||
{
|
{
|
||||||
filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "user", "logs");
|
_filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "user", "logs");
|
||||||
}
|
_logFile = Path.Combine(_filePath, "launcher.log");
|
||||||
|
|
||||||
public void Write(string text)
|
if (File.Exists(_logFile))
|
||||||
{
|
|
||||||
if (!Directory.Exists(filepath))
|
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(filepath);
|
File.Delete(_logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
string filename = Path.Combine(filepath, "launcher.log");
|
Write($" ==== Launcher Started ====");
|
||||||
File.AppendAllLines(filename, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{text}" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Debug(string text) => Write($"[Debug]{text}");
|
private void Write(string text)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(_filePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_filePath);
|
||||||
|
}
|
||||||
|
|
||||||
public void Info(string text) => Write($"[Info]{text}");
|
File.AppendAllLines(_logFile, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{text}" });
|
||||||
|
}
|
||||||
|
|
||||||
public void Warning(string text) => Write($"[Warning]{text}");
|
public void Debug(string text) => Write($"[Debug] {text}");
|
||||||
|
|
||||||
public void Error(string text) => Write($"[Error]{text}");
|
public void Info(string text) => Write($"[Info] {text}");
|
||||||
|
|
||||||
public void Exception(Exception ex) => Write($"[Exception]{ex.Message}\nStacktrace:\n{ex.StackTrace}");
|
public void Warning(string text) => Write($"[Warning] {text}");
|
||||||
|
|
||||||
|
public void Error(string text) => Write($"[Error] {text}");
|
||||||
|
|
||||||
|
public void Exception(Exception ex) => Write($"[Exception] {ex.Message}\nStacktrace:\n{ex.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ using Newtonsoft.Json;
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Aki.Launcher.Controllers;
|
||||||
|
|
||||||
namespace Aki.Launcher.Helpers
|
namespace Aki.Launcher.Helpers
|
||||||
{
|
{
|
||||||
@ -142,6 +143,8 @@ namespace Aki.Launcher.Helpers
|
|||||||
{
|
{
|
||||||
if (!File.Exists(LauncherSettingsProvider.DefaultSettingsFileLocation))
|
if (!File.Exists(LauncherSettingsProvider.DefaultSettingsFileLocation))
|
||||||
{
|
{
|
||||||
|
LogManager.Instance.Warning("Launcher config not found");
|
||||||
|
LogManager.Instance.Info($"Creating launcher config: {LauncherSettingsProvider.DefaultSettingsFileLocation}");
|
||||||
LauncherStartGameAction = LauncherAction.MinimizeAction;
|
LauncherStartGameAction = LauncherAction.MinimizeAction;
|
||||||
UseAutoLogin = true;
|
UseAutoLogin = true;
|
||||||
GamePath = Environment.CurrentDirectory;
|
GamePath = Environment.CurrentDirectory;
|
||||||
@ -149,6 +152,8 @@ namespace Aki.Launcher.Helpers
|
|||||||
Server = new ServerSetting { Name = "SPT-AKI", Url = "http://127.0.0.1:6969" };
|
Server = new ServerSetting { Name = "SPT-AKI", Url = "http://127.0.0.1:6969" };
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogManager.Instance.Info($"Using launcher config at: {LauncherSettingsProvider.DefaultSettingsFileLocation}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
@ -16,6 +16,7 @@ using System.ComponentModel;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Aki.Launcher.Controllers;
|
||||||
|
|
||||||
namespace Aki.Launcher.Helpers
|
namespace Aki.Launcher.Helpers
|
||||||
{
|
{
|
||||||
@ -41,7 +42,8 @@ namespace Aki.Launcher.Helpers
|
|||||||
|
|
||||||
public static void LoadLocaleFromFile(string localeRomanName)
|
public static void LoadLocaleFromFile(string localeRomanName)
|
||||||
{
|
{
|
||||||
LocaleData newLocale = Json.LoadClassWithoutSaving<LocaleData>(Path.Join(DefaultLocaleFolderPath, $"{localeRomanName}.json"));
|
var localePath = Path.Join(DefaultLocaleFolderPath, $"{localeRomanName}.json");
|
||||||
|
LocaleData newLocale = Json.LoadClassWithoutSaving<LocaleData>(localePath);
|
||||||
|
|
||||||
if (newLocale != null)
|
if (newLocale != null)
|
||||||
{
|
{
|
||||||
@ -54,9 +56,11 @@ namespace Aki.Launcher.Helpers
|
|||||||
LauncherSettingsProvider.Instance.SaveSettings();
|
LauncherSettingsProvider.Instance.SaveSettings();
|
||||||
|
|
||||||
LocaleChanged(null, EventArgs.Empty);
|
LocaleChanged(null, EventArgs.Empty);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//could possibly raise an event here to say why the local wasn't changed.
|
LogManager.Instance.Error($"Could not load locale: {localePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TryAutoSetLocale()
|
public static void TryAutoSetLocale()
|
||||||
|
@ -59,5 +59,10 @@ namespace Aki.Launcher.Models.Aki
|
|||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return HasTag ? $"{Major}.{Minor}.{Build}-{Tag}" : $"{Major}.{Minor}.{Build}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using ReactiveUI;
|
|||||||
using Splat;
|
using Splat;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Aki.Launcher.Controllers;
|
||||||
|
|
||||||
namespace Aki.Launcher.ViewModels
|
namespace Aki.Launcher.ViewModels
|
||||||
{
|
{
|
||||||
@ -52,6 +53,8 @@ namespace Aki.Launcher.ViewModels
|
|||||||
|
|
||||||
version.ParseVersionInfo(ServerManager.GetVersion());
|
version.ParseVersionInfo(ServerManager.GetVersion());
|
||||||
|
|
||||||
|
LogManager.Instance.Info($"Connected to server: {ServerManager.SelectedServer.backendUrl} - Aki Version: {version}");
|
||||||
|
|
||||||
NavigateTo(new LoginViewModel(HostScreen, noAutoLogin));
|
NavigateTo(new LoginViewModel(HostScreen, noAutoLogin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user