From 04f94b44ad40f902fb6578a04adcc92c01a75433 Mon Sep 17 00:00:00 2001 From: Vasilis The Pikachu Date: Fri, 5 Jan 2024 21:26:41 +0100 Subject: [PATCH 1/7] Make launcher logging default --- SS14.Launcher/LauncherPaths.cs | 2 +- SS14.Launcher/Models/Data/CVars.cs | 5 ----- SS14.Launcher/Program.cs | 14 ++++++-------- .../ViewModels/MainWindowLoginViewModel.cs | 11 ----------- .../MainWindowTabs/OptionsTabViewModel.cs | 10 ---------- SS14.Launcher/Views/MainWindowLogin.xaml | 2 -- .../Views/MainWindowTabs/OptionsTabView.xaml | 5 ----- 7 files changed, 7 insertions(+), 42 deletions(-) diff --git a/SS14.Launcher/LauncherPaths.cs b/SS14.Launcher/LauncherPaths.cs index beb75c71..98ed6adf 100644 --- a/SS14.Launcher/LauncherPaths.cs +++ b/SS14.Launcher/LauncherPaths.cs @@ -14,7 +14,7 @@ public static class LauncherPaths public static readonly string EngineModulesDirName = "modules"; public static readonly string ServerContentDirName = "server content"; public static readonly string LogsDirName = "logs"; - public static readonly string LauncherLogName = "launcher.log"; + public static readonly string LauncherLogName = "launcher-.log"; public static readonly string ClientMacLogName = "client.mac.log"; public static readonly string ClientStdoutLogName = "client.stdout.log"; public static readonly string ClientStderrLogName = "client.stderr.log"; diff --git a/SS14.Launcher/Models/Data/CVars.cs b/SS14.Launcher/Models/Data/CVars.cs index ae6977ce..30e406f4 100644 --- a/SS14.Launcher/Models/Data/CVars.cs +++ b/SS14.Launcher/Models/Data/CVars.cs @@ -61,11 +61,6 @@ public static readonly CVarDef HasDismissedEarlyAccessWarning /// public static readonly CVarDef LogClient = CVarDef.Create("LogClient", false); - /// - /// Enable logging of launched client instances to file. - /// - public static readonly CVarDef LogLauncher = CVarDef.Create("LogLauncher", false); - /// /// Verbose logging of launcher logs. /// diff --git a/SS14.Launcher/Program.cs b/SS14.Launcher/Program.cs index 3976c242..9629aab4 100644 --- a/SS14.Launcher/Program.cs +++ b/SS14.Launcher/Program.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Net.Http.Headers; using System.Text; @@ -102,14 +103,11 @@ public static void Main(string[] args) // Bad antivirus check disabled: I assume Avast/AVG fixed their shit. // CheckBadAntivirus(); - if (cfg.GetCVar(CVars.LogLauncher)) - { - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Is(cfg.GetCVar(CVars.LogLauncherVerbose) ? LogEventLevel.Verbose : LogEventLevel.Debug) - .WriteTo.Console(theme: AnsiConsoleTheme.Sixteen) - .WriteTo.File(LauncherPaths.PathLauncherLog) - .CreateLogger(); - } + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Is(cfg.GetCVar(CVars.LogLauncherVerbose) ? LogEventLevel.Verbose : LogEventLevel.Debug) + .WriteTo.Console(theme: AnsiConsoleTheme.Sixteen) + .WriteTo.File(LauncherPaths.PathLauncherLog, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 1) + .CreateLogger(); LauncherDiagnostics.LogDiagnostics(); diff --git a/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs b/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs index dc8758f1..e94ed41e 100644 --- a/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs +++ b/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs @@ -71,15 +71,4 @@ public void SwitchToRegisterNeedsConfirmation(string username, string password) { Screen = new RegisterNeedsConfirmationViewModel(this, _authApi, username, password, _loginMgr, _cfg); } - - public bool LogLauncher - { - // This not a clean solution, replace it with something better. - get => _cfg.GetCVar(CVars.LogLauncher); - set - { - _cfg.SetCVar(CVars.LogLauncher, value); - _cfg.CommitConfig(); - } - } } diff --git a/SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs b/SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs index c37b4f72..855e7e65 100644 --- a/SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs +++ b/SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs @@ -58,16 +58,6 @@ public bool LogClient } } - public bool LogLauncher - { - get => Cfg.GetCVar(CVars.LogLauncher); - set - { - Cfg.SetCVar(CVars.LogLauncher, value); - Cfg.CommitConfig(); - } - } - public bool LogLauncherVerbose { get => Cfg.GetCVar(CVars.LogLauncherVerbose); diff --git a/SS14.Launcher/Views/MainWindowLogin.xaml b/SS14.Launcher/Views/MainWindowLogin.xaml index 707a7517..3839b807 100644 --- a/SS14.Launcher/Views/MainWindowLogin.xaml +++ b/SS14.Launcher/Views/MainWindowLogin.xaml @@ -16,8 +16,6 @@ - Log Launcher - diff --git a/SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml b/SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml index 0325840c..d6255a75 100644 --- a/SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml +++ b/SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml @@ -41,11 +41,6 @@ Text="Enables logging of any game client output. Useful for developers." Margin="8" /> - Log Launcher - - Verbose Launcher Logging Date: Wed, 10 Jan 2024 17:13:28 +0100 Subject: [PATCH 2/7] Add open logs button for convenience on the login screen --- SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs | 10 ++++++++++ SS14.Launcher/Views/MainWindowLogin.xaml | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs b/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs index e94ed41e..1f2b77bf 100644 --- a/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs +++ b/SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using ReactiveUI; using Splat; using SS14.Launcher.Api; @@ -71,4 +72,13 @@ public void SwitchToRegisterNeedsConfirmation(string username, string password) { Screen = new RegisterNeedsConfirmationViewModel(this, _authApi, username, password, _loginMgr, _cfg); } + + public void OpenLogDirectory() + { + Process.Start(new ProcessStartInfo + { + UseShellExecute = true, + FileName = LauncherPaths.DirLogs + }); + } } diff --git a/SS14.Launcher/Views/MainWindowLogin.xaml b/SS14.Launcher/Views/MainWindowLogin.xaml index 3839b807..5ee7c26f 100644 --- a/SS14.Launcher/Views/MainWindowLogin.xaml +++ b/SS14.Launcher/Views/MainWindowLogin.xaml @@ -15,9 +15,10 @@ - +