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 ulong _logLength = 0;
|
||||
private static readonly ulong _maxLogCharacterLength = 500000000;
|
||||
private static bool _limitsFileSize = true;
|
||||
|
||||
string ILogTarget.Name { get => _name; }
|
||||
|
||||
public FileLogTarget(string name, FileStream fileStream)
|
||||
public FileLogTarget(string name, FileStream fileStream, bool limitsFileSize)
|
||||
{
|
||||
_name = name;
|
||||
_logWriter = new StreamWriter(fileStream);
|
||||
_formatter = new DefaultLogFormatter();
|
||||
_limitsFileSize = limitsFileSize;
|
||||
}
|
||||
|
||||
public static FileStream PrepareLogFile(string path)
|
||||
|
@ -97,12 +99,12 @@ namespace Ryujinx.Common.Logging.Targets
|
|||
{
|
||||
string toWrite = _formatter.Format(args);
|
||||
_logLength += (ulong)toWrite.Length;
|
||||
if (_logLength <= _maxLogCharacterLength)
|
||||
|
||||
if (_logLength <= _maxLogCharacterLength || !_limitsFileSize)
|
||||
{
|
||||
_logWriter.WriteLine(toWrite);
|
||||
_logWriter.Flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.")]
|
||||
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
|
||||
|
||||
[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)
|
||||
{
|
||||
bool limitsFileSize = !option.LoggingDisableLogFileSizeLimit;
|
||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||
new FileLogTarget("file", logFile),
|
||||
new FileLogTarget("file", logFile, limitsFileSize),
|
||||
1000,
|
||||
AsyncLogTargetOverflowAction.Block
|
||||
));
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
/// <summary>
|
||||
/// The current version of the file format
|
||||
/// </summary>
|
||||
public const int CurrentVersion = 51;
|
||||
public const int CurrentVersion = 52;
|
||||
|
||||
/// <summary>
|
||||
/// Version of the configuration file format
|
||||
|
@ -122,6 +122,11 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
/// </summary>
|
||||
public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Disables the 500MB log file size limit.
|
||||
/// </summary>
|
||||
public bool LoggingDisableLogFileSizeLimit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Change System Language
|
||||
/// </summary>
|
||||
|
|
|
@ -269,6 +269,11 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
/// </summary>
|
||||
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()
|
||||
{
|
||||
EnableDebug = new ReactiveObject<bool>();
|
||||
|
@ -283,6 +288,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
EnableFileLog = new ReactiveObject<bool>();
|
||||
EnableFileLog.Event += static (sender, e) => LogValueChange(e, nameof(EnableFileLog));
|
||||
GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
|
||||
DisableLogFileSizeLimit = new ReactiveObject<bool>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,6 +689,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
|
||||
LoggingFilteredClasses = Logger.FilteredClasses,
|
||||
LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
|
||||
LoggingDisableLogFileSizeLimit = Logger.DisableLogFileSizeLimit,
|
||||
SystemLanguage = System.Language,
|
||||
SystemRegion = System.Region,
|
||||
SystemTimeZone = System.TimeZone,
|
||||
|
@ -790,6 +797,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
Logger.EnableTrace.Value = false;
|
||||
Logger.EnableGuest.Value = true;
|
||||
Logger.EnableFsAccessLog.Value = false;
|
||||
Logger.DisableLogFileSizeLimit.Value = false;
|
||||
Logger.FilteredClasses.Value = Array.Empty<LogClass>();
|
||||
Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
|
||||
System.Language.Value = Language.AmericanEnglish;
|
||||
|
@ -1477,6 +1485,13 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
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;
|
||||
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
||||
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
||||
|
@ -1497,6 +1512,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
|
||||
Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
|
||||
Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
|
||||
Logger.DisableLogFileSizeLimit.Value = configurationFileFormat.LoggingDisableLogFileSizeLimit;
|
||||
Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
|
||||
Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
|
||||
System.Language.Value = configurationFileFormat.SystemLanguage;
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
ConfigurationState.Instance.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog;
|
||||
ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses;
|
||||
ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger;
|
||||
ConfigurationState.Instance.Logger.DisableLogFileSizeLimit.Event += ReloadDisableLogFileSizeLimit;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (e.NewValue)
|
||||
|
@ -98,8 +107,10 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
return;
|
||||
}
|
||||
|
||||
bool limitsFileSize = !ConfigurationState.Instance.Logger.DisableLogFileSizeLimit;
|
||||
|
||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||
new FileLogTarget("file", logFile),
|
||||
new FileLogTarget("file", logFile, limitsFileSize),
|
||||
1000,
|
||||
AsyncLogTargetOverflowAction.Block
|
||||
));
|
||||
|
|
|
@ -189,6 +189,7 @@
|
|||
"SettingsTabLoggingGraphicsBackendLogLevelPerformance": "Slowdowns",
|
||||
"SettingsTabLoggingGraphicsBackendLogLevelAll": "All",
|
||||
"SettingsTabLoggingEnableDebugLogs": "Enable Debug Logs",
|
||||
"SettingsTabLoggingDisableLogFileSizeLimit": "Disable Log File Size Limit",
|
||||
"SettingsTabInput": "Input",
|
||||
"SettingsTabInputEnableDockedMode": "Docked Mode",
|
||||
"SettingsTabInputDirectKeyboardAccess": "Direct Keyboard Access",
|
||||
|
@ -596,6 +597,7 @@
|
|||
"DeveloperOptionTooltip": "Use with care",
|
||||
"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.",
|
||||
"DisableLogFileSizeTooltip": "Removes the 500MB limit on log file size.",
|
||||
"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",
|
||||
"OpenRyujinxFolderTooltip": "Open Ryujinx filesystem folder",
|
||||
|
|
|
@ -156,6 +156,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
public bool EnableGuest { get; set; }
|
||||
public bool EnableFsAccessLog { get; set; }
|
||||
public bool EnableDebug { get; set; }
|
||||
public bool DisableLogFileSizeLimit { get; set; }
|
||||
public bool IsOpenAlEnabled { get; set; }
|
||||
public bool IsSoundIoEnabled { get; set; }
|
||||
public bool IsSDL2Enabled { get; set; }
|
||||
|
@ -471,6 +472,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
|
||||
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
|
||||
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
||||
DisableLogFileSizeLimit = config.Logger.DisableLogFileSizeLimit;
|
||||
|
||||
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
|
||||
}
|
||||
|
@ -577,6 +579,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
config.Logger.EnableFsAccessLog.Value = EnableFsAccessLog;
|
||||
config.System.FsGlobalAccessLogMode.Value = FsGlobalAccessLogMode;
|
||||
config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel;
|
||||
config.Logger.DisableLogFileSizeLimit.Value = DisableLogFileSizeLimit;
|
||||
|
||||
config.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[NetworkInterfaceIndex]];
|
||||
config.Multiplayer.Mode.Value = (MultiplayerMode)MultiplayerModeIndex;
|
||||
|
|
|
@ -74,6 +74,10 @@
|
|||
ToolTip.Tip="{locale:Locale DebugLogTooltip}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableDebugLogs}" />
|
||||
</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">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
ToolTip.Tip="{locale:Locale FSAccessLogModeTooltip}"
|
||||
|
|
Loading…
Reference in a new issue