Add Settings toggle for log filesize limit
This commit is contained in:
parent
7a7eba6254
commit
3dd722ed3f
9 changed files with 54 additions and 7 deletions
|
@ -12,14 +12,16 @@ namespace Ryujinx.Common.Logging.Targets
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
private ulong _logLength = 0;
|
private ulong _logLength = 0;
|
||||||
private static readonly ulong _maxLogCharacterLength = 500000000;
|
private static readonly ulong _maxLogCharacterLength = 500000000;
|
||||||
|
private static bool _limitsFileSize = true;
|
||||||
|
|
||||||
string ILogTarget.Name { get => _name; }
|
string ILogTarget.Name { get => _name; }
|
||||||
|
|
||||||
public FileLogTarget(string name, FileStream fileStream)
|
public FileLogTarget(string name, FileStream fileStream, bool limitsFileSize)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_logWriter = new StreamWriter(fileStream);
|
_logWriter = new StreamWriter(fileStream);
|
||||||
_formatter = new DefaultLogFormatter();
|
_formatter = new DefaultLogFormatter();
|
||||||
|
_limitsFileSize = limitsFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileStream PrepareLogFile(string path)
|
public static FileStream PrepareLogFile(string path)
|
||||||
|
@ -97,12 +99,12 @@ namespace Ryujinx.Common.Logging.Targets
|
||||||
{
|
{
|
||||||
string toWrite = _formatter.Format(args);
|
string toWrite = _formatter.Format(args);
|
||||||
_logLength += (ulong)toWrite.Length;
|
_logLength += (ulong)toWrite.Length;
|
||||||
if (_logLength <= _maxLogCharacterLength)
|
|
||||||
|
if (_logLength <= _maxLogCharacterLength || !_limitsFileSize)
|
||||||
{
|
{
|
||||||
_logWriter.WriteLine(toWrite);
|
_logWriter.WriteLine(toWrite);
|
||||||
_logWriter.Flush();
|
_logWriter.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -182,6 +182,9 @@ namespace Ryujinx.Headless.SDL2
|
||||||
[Option("graphics-debug-level", Required = false, Default = GraphicsDebugLevel.None, HelpText = "Change Graphics API debug log level.")]
|
[Option("graphics-debug-level", Required = false, Default = GraphicsDebugLevel.None, HelpText = "Change Graphics API debug log level.")]
|
||||||
public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
|
public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
|
||||||
|
|
||||||
|
[Option("disable-log-size-limit", Required = false, Default = false, HelpText = "Disable 500MB log file size limit.")]
|
||||||
|
public bool LoggingDisableLogFileSizeLimit { get; set; }
|
||||||
|
|
||||||
// Graphics
|
// Graphics
|
||||||
|
|
||||||
[Option("resolution-scale", Required = false, Default = 1, HelpText = "Resolution Scale. A floating point scale applied to applicable render targets.")]
|
[Option("resolution-scale", Required = false, Default = 1, HelpText = "Resolution Scale. A floating point scale applied to applicable render targets.")]
|
||||||
|
|
|
@ -437,8 +437,9 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
if (logFile != null)
|
if (logFile != null)
|
||||||
{
|
{
|
||||||
|
bool limitsFileSize = !option.LoggingDisableLogFileSizeLimit;
|
||||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||||
new FileLogTarget("file", logFile),
|
new FileLogTarget("file", logFile, limitsFileSize),
|
||||||
1000,
|
1000,
|
||||||
AsyncLogTargetOverflowAction.Block
|
AsyncLogTargetOverflowAction.Block
|
||||||
));
|
));
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of the file format
|
/// The current version of the file format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int CurrentVersion = 51;
|
public const int CurrentVersion = 52;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the configuration file format
|
/// Version of the configuration file format
|
||||||
|
@ -122,6 +122,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
|
public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disables the 500MB log file size limit.
|
||||||
|
/// </summary>
|
||||||
|
public bool LoggingDisableLogFileSizeLimit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change System Language
|
/// Change System Language
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -269,6 +269,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<GraphicsDebugLevel> GraphicsDebugLevel { get; private set; }
|
public ReactiveObject<GraphicsDebugLevel> GraphicsDebugLevel { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disables the 500MB imposed file size limit on logs.
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<bool> DisableLogFileSizeLimit { get; private set; }
|
||||||
|
|
||||||
public LoggerSection()
|
public LoggerSection()
|
||||||
{
|
{
|
||||||
EnableDebug = new ReactiveObject<bool>();
|
EnableDebug = new ReactiveObject<bool>();
|
||||||
|
@ -283,6 +288,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
EnableFileLog = new ReactiveObject<bool>();
|
EnableFileLog = new ReactiveObject<bool>();
|
||||||
EnableFileLog.Event += static (sender, e) => LogValueChange(e, nameof(EnableFileLog));
|
EnableFileLog.Event += static (sender, e) => LogValueChange(e, nameof(EnableFileLog));
|
||||||
GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
|
GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
|
||||||
|
DisableLogFileSizeLimit = new ReactiveObject<bool>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,6 +689,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
|
LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
|
||||||
LoggingFilteredClasses = Logger.FilteredClasses,
|
LoggingFilteredClasses = Logger.FilteredClasses,
|
||||||
LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
|
LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
|
||||||
|
LoggingDisableLogFileSizeLimit = Logger.DisableLogFileSizeLimit,
|
||||||
SystemLanguage = System.Language,
|
SystemLanguage = System.Language,
|
||||||
SystemRegion = System.Region,
|
SystemRegion = System.Region,
|
||||||
SystemTimeZone = System.TimeZone,
|
SystemTimeZone = System.TimeZone,
|
||||||
|
@ -790,6 +797,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
Logger.EnableTrace.Value = false;
|
Logger.EnableTrace.Value = false;
|
||||||
Logger.EnableGuest.Value = true;
|
Logger.EnableGuest.Value = true;
|
||||||
Logger.EnableFsAccessLog.Value = false;
|
Logger.EnableFsAccessLog.Value = false;
|
||||||
|
Logger.DisableLogFileSizeLimit.Value = false;
|
||||||
Logger.FilteredClasses.Value = Array.Empty<LogClass>();
|
Logger.FilteredClasses.Value = Array.Empty<LogClass>();
|
||||||
Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
|
Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
|
||||||
System.Language.Value = Language.AmericanEnglish;
|
System.Language.Value = Language.AmericanEnglish;
|
||||||
|
@ -1477,6 +1485,13 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
configurationFileUpdated = true;
|
configurationFileUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configurationFileFormat.Version < 52)
|
||||||
|
{
|
||||||
|
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 52.");
|
||||||
|
|
||||||
|
configurationFileFormat.LoggingDisableLogFileSizeLimit = false;
|
||||||
|
}
|
||||||
|
|
||||||
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
||||||
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
||||||
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
||||||
|
@ -1497,6 +1512,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
|
Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
|
||||||
Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
|
Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
|
||||||
Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
|
Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
|
||||||
|
Logger.DisableLogFileSizeLimit.Value = configurationFileFormat.LoggingDisableLogFileSizeLimit;
|
||||||
Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
|
Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
|
||||||
Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
|
Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
|
||||||
System.Language.Value = configurationFileFormat.SystemLanguage;
|
System.Language.Value = configurationFileFormat.SystemLanguage;
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
ConfigurationState.Instance.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog;
|
ConfigurationState.Instance.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog;
|
||||||
ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses;
|
ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses;
|
||||||
ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger;
|
ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger;
|
||||||
|
ConfigurationState.Instance.Logger.DisableLogFileSizeLimit.Event += ReloadDisableLogFileSizeLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e)
|
||||||
|
@ -78,6 +79,14 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ReloadDisableLogFileSizeLimit(object sender, ReactiveEventArgs<bool> e)
|
||||||
|
{
|
||||||
|
//TODO: add function to add or remove the file size limit during runtime.
|
||||||
|
//NOTE: Is this needed? If we want it, we would need to add a function on ILogTarget to do the job
|
||||||
|
//or some mechanism to directly access the FileLogTarget via AsyncLogTargetWrapper. For now,
|
||||||
|
//changes to this value only take effect after restart (which is probably what the user wants anyway).
|
||||||
|
}
|
||||||
|
|
||||||
private static void ReloadFileLogger(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadFileLogger(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
if (e.NewValue)
|
if (e.NewValue)
|
||||||
|
@ -98,8 +107,10 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool limitsFileSize = !ConfigurationState.Instance.Logger.DisableLogFileSizeLimit;
|
||||||
|
|
||||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||||
new FileLogTarget("file", logFile),
|
new FileLogTarget("file", logFile, limitsFileSize),
|
||||||
1000,
|
1000,
|
||||||
AsyncLogTargetOverflowAction.Block
|
AsyncLogTargetOverflowAction.Block
|
||||||
));
|
));
|
||||||
|
|
|
@ -189,6 +189,7 @@
|
||||||
"SettingsTabLoggingGraphicsBackendLogLevelPerformance": "Slowdowns",
|
"SettingsTabLoggingGraphicsBackendLogLevelPerformance": "Slowdowns",
|
||||||
"SettingsTabLoggingGraphicsBackendLogLevelAll": "All",
|
"SettingsTabLoggingGraphicsBackendLogLevelAll": "All",
|
||||||
"SettingsTabLoggingEnableDebugLogs": "Enable Debug Logs",
|
"SettingsTabLoggingEnableDebugLogs": "Enable Debug Logs",
|
||||||
|
"SettingsTabLoggingDisableLogFileSizeLimit": "Disable Log File Size Limit",
|
||||||
"SettingsTabInput": "Input",
|
"SettingsTabInput": "Input",
|
||||||
"SettingsTabInputEnableDockedMode": "Docked Mode",
|
"SettingsTabInputEnableDockedMode": "Docked Mode",
|
||||||
"SettingsTabInputDirectKeyboardAccess": "Direct Keyboard Access",
|
"SettingsTabInputDirectKeyboardAccess": "Direct Keyboard Access",
|
||||||
|
@ -596,6 +597,7 @@
|
||||||
"DeveloperOptionTooltip": "Use with care",
|
"DeveloperOptionTooltip": "Use with care",
|
||||||
"OpenGlLogLevel": "Requires appropriate log levels enabled",
|
"OpenGlLogLevel": "Requires appropriate log levels enabled",
|
||||||
"DebugLogTooltip": "Prints debug log messages in the console.\n\nOnly use this if specifically instructed by a staff member, as it will make logs difficult to read and worsen emulator performance.",
|
"DebugLogTooltip": "Prints debug log messages in the console.\n\nOnly use this if specifically instructed by a staff member, as it will make logs difficult to read and worsen emulator performance.",
|
||||||
|
"DisableLogFileSizeTooltip": "Removes the 500MB limit on log file size.",
|
||||||
"LoadApplicationFileTooltip": "Open a file explorer to choose a Switch compatible file to load",
|
"LoadApplicationFileTooltip": "Open a file explorer to choose a Switch compatible file to load",
|
||||||
"LoadApplicationFolderTooltip": "Open a file explorer to choose a Switch compatible, unpacked application to load",
|
"LoadApplicationFolderTooltip": "Open a file explorer to choose a Switch compatible, unpacked application to load",
|
||||||
"OpenRyujinxFolderTooltip": "Open Ryujinx filesystem folder",
|
"OpenRyujinxFolderTooltip": "Open Ryujinx filesystem folder",
|
||||||
|
|
|
@ -156,6 +156,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
public bool EnableGuest { get; set; }
|
public bool EnableGuest { get; set; }
|
||||||
public bool EnableFsAccessLog { get; set; }
|
public bool EnableFsAccessLog { get; set; }
|
||||||
public bool EnableDebug { get; set; }
|
public bool EnableDebug { get; set; }
|
||||||
|
public bool DisableLogFileSizeLimit { get; set; }
|
||||||
public bool IsOpenAlEnabled { get; set; }
|
public bool IsOpenAlEnabled { get; set; }
|
||||||
public bool IsSoundIoEnabled { get; set; }
|
public bool IsSoundIoEnabled { get; set; }
|
||||||
public bool IsSDL2Enabled { get; set; }
|
public bool IsSDL2Enabled { get; set; }
|
||||||
|
@ -471,6 +472,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
|
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
|
||||||
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
|
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
|
||||||
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
||||||
|
DisableLogFileSizeLimit = config.Logger.DisableLogFileSizeLimit;
|
||||||
|
|
||||||
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
|
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
|
||||||
}
|
}
|
||||||
|
@ -577,6 +579,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
config.Logger.EnableFsAccessLog.Value = EnableFsAccessLog;
|
config.Logger.EnableFsAccessLog.Value = EnableFsAccessLog;
|
||||||
config.System.FsGlobalAccessLogMode.Value = FsGlobalAccessLogMode;
|
config.System.FsGlobalAccessLogMode.Value = FsGlobalAccessLogMode;
|
||||||
config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel;
|
config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel;
|
||||||
|
config.Logger.DisableLogFileSizeLimit.Value = DisableLogFileSizeLimit;
|
||||||
|
|
||||||
config.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[NetworkInterfaceIndex]];
|
config.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[NetworkInterfaceIndex]];
|
||||||
config.Multiplayer.Mode.Value = (MultiplayerMode)MultiplayerModeIndex;
|
config.Multiplayer.Mode.Value = (MultiplayerMode)MultiplayerModeIndex;
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
ToolTip.Tip="{locale:Locale DebugLogTooltip}">
|
ToolTip.Tip="{locale:Locale DebugLogTooltip}">
|
||||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableDebugLogs}" />
|
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableDebugLogs}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox IsChecked="{Binding DisableLogFileSizeLimit}"
|
||||||
|
ToolTip.Tip="{locale:Locale DisableLogFileSizeTooltip}">
|
||||||
|
<TextBlock Text="{locale:Locale SettingsTabLoggingDisableLogFileSizeLimit}" />
|
||||||
|
</CheckBox>
|
||||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" VerticalAlignment="Stretch">
|
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" VerticalAlignment="Stretch">
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
ToolTip.Tip="{locale:Locale FSAccessLogModeTooltip}"
|
ToolTip.Tip="{locale:Locale FSAccessLogModeTooltip}"
|
||||||
|
|
Loading…
Reference in a new issue