Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make logging default (and clear out launcher logs each day) #131

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion SS14.Launcher/LauncherPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
20 changes: 8 additions & 12 deletions SS14.Launcher/Models/Connector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,17 @@ private async Task<ContentLaunchInfo> InstallContentBundleAsync(

EnvVar("SS14_LAUNCHER_PATH", Process.GetCurrentProcess().MainModule!.FileName);

// ReSharper disable once ReplaceWithSingleAssignment.False
var manualPipeLogging = false;
if (_cfg.GetCVar(CVars.LogClient))
{
manualPipeLogging = true;

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
EnvVar("SS14_LOG_CLIENT", LauncherPaths.PathClientMacLog);
}
// Enable client logging.
var manualPipeLogging = true;

startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
EnvVar("SS14_LOG_CLIENT", LauncherPaths.PathClientMacLog);
}

startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;

// Performance tweaks
EnvVar("DOTNET_TieredPGO", "1");
EnvVar("DOTNET_ReadyToRun", "0");
Expand Down
10 changes: 0 additions & 10 deletions SS14.Launcher/Models/Data/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ public static readonly CVarDef<bool> HasDismissedEarlyAccessWarning
/// </summary>
public static readonly CVarDef<string> EngineOverridePath = CVarDef.Create("EngineOverridePath", "");

/// <summary>
/// Enable logging of launched client instances to file.
/// </summary>
public static readonly CVarDef<bool> LogClient = CVarDef.Create("LogClient", false);

/// <summary>
/// Enable logging of launched client instances to file.
/// </summary>
public static readonly CVarDef<bool> LogLauncher = CVarDef.Create("LogLauncher", false);

/// <summary>
/// Verbose logging of launcher logs.
/// </summary>
Expand Down
14 changes: 6 additions & 8 deletions SS14.Launcher/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
Expand Down Expand Up @@ -104,14 +105,11 @@ public static void Main(string[] args)
// CheckBadAntivirus();
CheckWine(cfg);

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();

Expand Down
13 changes: 6 additions & 7 deletions SS14.Launcher/ViewModels/MainWindowLoginViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using ReactiveUI;
using Splat;
using SS14.Launcher.Api;
Expand Down Expand Up @@ -72,14 +73,12 @@ public void SwitchToRegisterNeedsConfirmation(string username, string password)
Screen = new RegisterNeedsConfirmationViewModel(this, _authApi, username, password, _loginMgr, _cfg);
}

public bool LogLauncher
public void OpenLogDirectory()
{
// This not a clean solution, replace it with something better.
get => _cfg.GetCVar(CVars.LogLauncher);
set
Process.Start(new ProcessStartInfo
{
_cfg.SetCVar(CVars.LogLauncher, value);
_cfg.CommitConfig();
}
UseShellExecute = true,
FileName = LauncherPaths.DirLogs
});
}
}
20 changes: 0 additions & 20 deletions SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,6 @@ public bool CompatMode
}
}

public bool LogClient
{
get => Cfg.GetCVar(CVars.LogClient);
set
{
Cfg.SetCVar(CVars.LogClient, value);
Cfg.CommitConfig();
}
}

public bool LogLauncher
{
get => Cfg.GetCVar(CVars.LogLauncher);
set
{
Cfg.SetCVar(CVars.LogLauncher, value);
Cfg.CommitConfig();
}
}

public bool LogLauncherVerbose
{
get => Cfg.GetCVar(CVars.LogLauncherVerbose);
Expand Down
3 changes: 2 additions & 1 deletion SS14.Launcher/Views/MainWindowLogin.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

<views:LanguageSelector DockPanel.Dock="Left" VerticalAlignment="Center" Margin="4" DataContext="{Binding LanguageSelector}" />

<CheckBox DockPanel.Dock="Left" VerticalAlignment="Center" Margin="4" IsChecked="{Binding LogLauncher}" Content="{loc:Loc login-log-launcher}" />
<Button Content="{loc:Loc tab-options-open-log-directory}" DockPanel.Dock="Left" HorizontalAlignment="Left"
Command="{Binding OpenLogDirectory}"/>
</DockPanel>
<Panel Background="{DynamicResource ThemeStripebackEdgeBrush}" MinHeight="2" DockPanel.Dock="Bottom" />

Expand Down
10 changes: 0 additions & 10 deletions SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@
Text="{loc:Loc tab-options-compatibility-mode-desc}"
Margin="8" />

<CheckBox VerticalAlignment="Center" Margin="4" IsChecked="{Binding LogClient}" Content="{loc:Loc tab-options-log-client}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap"
Text="{loc:Loc tab-options-log-client-desc}"
Margin="8" />

<CheckBox VerticalAlignment="Center" Margin="4" IsChecked="{Binding LogLauncher}" Content="{loc:Loc tab-options-log-launcher}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap"
Text="{loc:Loc tab-options-log-launcher-desc}"
Margin="8" />

<CheckBox VerticalAlignment="Center" Margin="4" IsChecked="{Binding LogLauncherVerbose}" Content="{loc:Loc tab-options-verbose-launcher-logging}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap"
Text="{loc:Loc tab-options-verbose-launcher-logging-desc}"
Expand Down
Loading