mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-12 16:30:42 -05:00
added more logging
This commit is contained in:
parent
e4fa976d73
commit
68347e39b2
@ -8,11 +8,13 @@
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using Aki.Launcher.Helpers;
|
||||
using Aki.Launcher.MiniCommon;
|
||||
using Aki.Launcher.Models.Aki;
|
||||
using Aki.Launcher.Models.Launcher;
|
||||
using System.Threading.Tasks;
|
||||
using Aki.Launcher.Controllers;
|
||||
|
||||
namespace Aki.Launcher
|
||||
{
|
||||
@ -135,6 +137,8 @@ namespace Aki.Launcher
|
||||
{
|
||||
return AccountStatus.NoConnection;
|
||||
}
|
||||
|
||||
LogManager.Instance.Info($"Account Registered: {username}");
|
||||
|
||||
return Login(username, password);
|
||||
}
|
||||
@ -159,16 +163,20 @@ namespace Aki.Launcher
|
||||
if(Json.Deserialize<bool>(json))
|
||||
{
|
||||
SelectedAccount = null;
|
||||
|
||||
LogManager.Instance.Info($"Account Removed: {data.username}");
|
||||
|
||||
return AccountStatus.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogManager.Instance.Error($"Failed to remove account: {data.username}");
|
||||
return AccountStatus.UpdateFailed;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
LogManager.Instance.Error($"Failed to remove account: {data.username} - NO CONNECTION");
|
||||
return AccountStatus.NoConnection;
|
||||
}
|
||||
}
|
||||
@ -271,15 +279,18 @@ namespace Aki.Launcher
|
||||
|
||||
if (json != STATUS_OK)
|
||||
{
|
||||
LogManager.Instance.Error($"Failed to wipe account: {data.username}");
|
||||
return AccountStatus.UpdateFailed;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
LogManager.Instance.Error($"Failed to wipe account: {data.username} - NO CONNECTION");
|
||||
return AccountStatus.NoConnection;
|
||||
}
|
||||
|
||||
SelectedAccount.edition = edition;
|
||||
LogManager.Instance.Info($"Account Wiped: {data.username} -> {edition}");
|
||||
return AccountStatus.OK;
|
||||
}
|
||||
}
|
||||
|
@ -57,23 +57,32 @@ namespace Aki.Launcher
|
||||
|
||||
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
|
||||
if (IsInstalledInLive())
|
||||
{
|
||||
LogManager.Instance.Warning("Failed installed in live check");
|
||||
LogManager.Instance.Error("[LaunchGame] Installed in Live :: YES");
|
||||
return GameStarterResult.FromError(-1);
|
||||
}
|
||||
|
||||
|
||||
LogManager.Instance.Info("[LaunchGame] Installed in Live :: NO");
|
||||
|
||||
LogManager.Instance.Info("[LaunchGame] Setup Game Files ...");
|
||||
SetupGameFiles(gamePath);
|
||||
|
||||
if (!ValidationUtil.Validate())
|
||||
{
|
||||
LogManager.Instance.Warning("Failed validation check");
|
||||
LogManager.Instance.Error("[LaunchGame] Game Validation :: FAILED");
|
||||
return GameStarterResult.FromError(-2);
|
||||
}
|
||||
|
||||
LogManager.Instance.Info("[LaunchGame] Game Validation :: OK");
|
||||
|
||||
if (account.wipe)
|
||||
{
|
||||
LogManager.Instance.Info("[LaunchGame] Wipe profile requested");
|
||||
RemoveRegistryKeys();
|
||||
CleanTempFiles();
|
||||
}
|
||||
@ -83,9 +92,12 @@ namespace Aki.Launcher
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
LogManager.Instance.Info("[LaunchGame] Valid Game Path :: OK");
|
||||
|
||||
// apply patches
|
||||
ProgressReportingPatchRunner patchRunner = new ProgressReportingPatchRunner(gamePath);
|
||||
@ -96,10 +108,12 @@ namespace Aki.Launcher
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
LogManager.Instance.Warning("Failed to apply assembly patch");
|
||||
LogManager.Instance.Error("[LaunchGame] Applying Patch :: FAILED");
|
||||
return GameStarterResult.FromError(-4);
|
||||
}
|
||||
|
||||
LogManager.Instance.Info("[LaunchGame] Applying Patch :: OK");
|
||||
|
||||
//start game
|
||||
var args =
|
||||
$"-force-gfx-jobs native -token={account.id} -config={Json.Serialize(new ClientConfig(server.backendUrl))}";
|
||||
@ -107,6 +121,7 @@ namespace Aki.Launcher
|
||||
if (_showOnly)
|
||||
{
|
||||
Console.WriteLine($"{clientExecutable} {args}");
|
||||
LogManager.Instance.Info("[LaunchGame] NOOP :: show only");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -118,6 +133,7 @@ namespace Aki.Launcher
|
||||
};
|
||||
|
||||
Process.Start(clientProcess);
|
||||
LogManager.Instance.Info("[LaunchGame] Game process started");
|
||||
}
|
||||
|
||||
return GameStarterResult.FromSuccess();
|
||||
@ -160,6 +176,7 @@ namespace Aki.Launcher
|
||||
if (File.Exists(file.FullName))
|
||||
{
|
||||
File.Delete(file.FullName);
|
||||
LogManager.Instance.Warning($"File removed :: found in live dir: {file.FullName}");
|
||||
isInstalledInLive = true;
|
||||
}
|
||||
}
|
||||
@ -169,6 +186,7 @@ namespace Aki.Launcher
|
||||
if (Directory.Exists(directory.FullName))
|
||||
{
|
||||
RemoveFilesRecurse(directory);
|
||||
LogManager.Instance.Warning($"Directory removed :: found in live dir: {directory.FullName}");
|
||||
isInstalledInLive = true;
|
||||
}
|
||||
}
|
||||
@ -237,6 +255,7 @@ namespace Aki.Launcher
|
||||
foreach (var value in key.GetValueNames())
|
||||
{
|
||||
key.DeleteValue(value);
|
||||
LogManager.Instance.Debug($"Removing reg key: {key.Name}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -266,6 +285,8 @@ namespace Aki.Launcher
|
||||
|
||||
bool RemoveFilesRecurse(DirectoryInfo basedir)
|
||||
{
|
||||
LogManager.Instance.Info($"Recursive Removal: {basedir}");
|
||||
|
||||
if (!basedir.Exists)
|
||||
{
|
||||
return true;
|
||||
@ -286,6 +307,7 @@ namespace Aki.Launcher
|
||||
{
|
||||
file.IsReadOnly = false;
|
||||
file.Delete();
|
||||
LogManager.Instance.Debug($" -> del file: {file.FullName}");
|
||||
}
|
||||
|
||||
// remove directory
|
||||
|
@ -17,35 +17,42 @@ namespace Aki.Launcher.Controllers
|
||||
/// </summary>
|
||||
public class LogManager
|
||||
{
|
||||
//TODO - update this to use reflection to get the calling method, class, etc
|
||||
private static LogManager _instance;
|
||||
public static LogManager Instance => _instance ?? (_instance = new LogManager());
|
||||
private string filepath;
|
||||
public static LogManager Instance => _instance ??= new LogManager();
|
||||
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");
|
||||
|
||||
if (File.Exists(_logFile))
|
||||
{
|
||||
File.Delete(_logFile);
|
||||
}
|
||||
|
||||
Write($" ==== Launcher Started ====");
|
||||
}
|
||||
|
||||
public void Write(string text)
|
||||
private void Write(string text)
|
||||
{
|
||||
if (!Directory.Exists(filepath))
|
||||
if (!Directory.Exists(_filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filepath);
|
||||
Directory.CreateDirectory(_filePath);
|
||||
}
|
||||
|
||||
string filename = Path.Combine(filepath, "launcher.log");
|
||||
File.AppendAllLines(filename, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{text}" });
|
||||
File.AppendAllLines(_logFile, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{text}" });
|
||||
}
|
||||
|
||||
public void Debug(string text) => Write($"[Debug]{text}");
|
||||
public void Debug(string text) => Write($"[Debug] {text}");
|
||||
|
||||
public void Info(string text) => Write($"[Info]{text}");
|
||||
public void Info(string text) => Write($"[Info] {text}");
|
||||
|
||||
public void Warning(string text) => Write($"[Warning]{text}");
|
||||
public void Warning(string text) => Write($"[Warning] {text}");
|
||||
|
||||
public void Error(string text) => Write($"[Error]{text}");
|
||||
public void Error(string text) => Write($"[Error] {text}");
|
||||
|
||||
public void Exception(Exception ex) => Write($"[Exception]{ex.Message}\nStacktrace:\n{ex.StackTrace}");
|
||||
public void Exception(Exception ex) => Write($"[Exception] {ex.Message}\nStacktrace:\n{ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using Aki.Launcher.Controllers;
|
||||
|
||||
namespace Aki.Launcher.Helpers
|
||||
{
|
||||
@ -142,6 +143,8 @@ namespace Aki.Launcher.Helpers
|
||||
{
|
||||
if (!File.Exists(LauncherSettingsProvider.DefaultSettingsFileLocation))
|
||||
{
|
||||
LogManager.Instance.Warning("Launcher config not found");
|
||||
LogManager.Instance.Info($"Creating launcher config: {LauncherSettingsProvider.DefaultSettingsFileLocation}");
|
||||
LauncherStartGameAction = LauncherAction.MinimizeAction;
|
||||
UseAutoLogin = true;
|
||||
GamePath = Environment.CurrentDirectory;
|
||||
@ -149,6 +152,8 @@ namespace Aki.Launcher.Helpers
|
||||
Server = new ServerSetting { Name = "SPT-AKI", Url = "http://127.0.0.1:6969" };
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
LogManager.Instance.Info($"Using launcher config at: {LauncherSettingsProvider.DefaultSettingsFileLocation}");
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
@ -16,6 +16,7 @@ using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Aki.Launcher.Controllers;
|
||||
|
||||
namespace Aki.Launcher.Helpers
|
||||
{
|
||||
@ -41,7 +42,8 @@ namespace Aki.Launcher.Helpers
|
||||
|
||||
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)
|
||||
{
|
||||
@ -54,9 +56,11 @@ namespace Aki.Launcher.Helpers
|
||||
LauncherSettingsProvider.Instance.SaveSettings();
|
||||
|
||||
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()
|
||||
|
@ -59,5 +59,10 @@ namespace Aki.Launcher.Models.Aki
|
||||
{
|
||||
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 System.Reactive.Disposables;
|
||||
using System.Threading.Tasks;
|
||||
using Aki.Launcher.Controllers;
|
||||
|
||||
namespace Aki.Launcher.ViewModels
|
||||
{
|
||||
@ -51,6 +52,8 @@ namespace Aki.Launcher.ViewModels
|
||||
AkiVersion version = Locator.Current.GetService<AkiVersion>("akiversion");
|
||||
|
||||
version.ParseVersionInfo(ServerManager.GetVersion());
|
||||
|
||||
LogManager.Instance.Info($"Connected to server: {ServerManager.SelectedServer.backendUrl} - Aki Version: {version}");
|
||||
|
||||
NavigateTo(new LoginViewModel(HostScreen, noAutoLogin));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user