0
0
Fork 0

Fix opening the wrong log directory (#6220)

This commit is contained in:
TSRBerry 2024-01-30 17:52:45 +01:00 committed by GitHub
parent ccbbaddbcb
commit 4505a7f162
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 9 deletions

View file

@ -1352,9 +1352,9 @@ namespace Ryujinx.Ava.UI.ViewModels
{
string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
if (ReleaseInformation.IsValid)
if (LoggerModule.LogDirectoryPath != null)
{
logPath = Path.Combine(AppDataManager.BaseDirPath, "Logs");
logPath = LoggerModule.LogDirectoryPath;
}
new DirectoryInfo(logPath).Create();

View file

@ -23,7 +23,7 @@ namespace Ryujinx.Common.Logging.Targets
public static FileStream PrepareLogFile(string path)
{
// Ensure directory is present
DirectoryInfo logDir = new(Path.Combine(path, "Logs"));
DirectoryInfo logDir = new(path);
try
{
logDir.Create();

View file

@ -427,11 +427,11 @@ namespace Ryujinx.Headless.SDL2
if (!option.DisableFileLog)
{
FileStream logFile = FileLogTarget.PrepareLogFile(AppDomain.CurrentDomain.BaseDirectory);
FileStream logFile = FileLogTarget.PrepareLogFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"));
if (logFile == null)
{
logFile = FileLogTarget.PrepareLogFile(AppDataManager.BaseDirPath);
logFile = FileLogTarget.PrepareLogFile(Path.Combine(AppDataManager.BaseDirPath, "Logs"));
if (logFile == null)
{

View file

@ -9,6 +9,8 @@ namespace Ryujinx.Ui.Common.Configuration
{
public static class LoggerModule
{
public static string LogDirectoryPath { get; private set; }
public static void Initialize()
{
ConfigurationState.Instance.Logger.EnableDebug.Event += ReloadEnableDebug;
@ -82,21 +84,26 @@ namespace Ryujinx.Ui.Common.Configuration
{
if (e.NewValue)
{
FileStream logFile = FileLogTarget.PrepareLogFile(AppDomain.CurrentDomain.BaseDirectory);
string logDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
FileStream logFile = FileLogTarget.PrepareLogFile(logDir);
if (logFile == null)
{
logFile = FileLogTarget.PrepareLogFile(AppDataManager.BaseDirPath);
logDir = Path.Combine(AppDataManager.BaseDirPath, "Logs");
logFile = FileLogTarget.PrepareLogFile(logDir);
if (logFile == null)
{
Logger.Error?.Print(LogClass.Application, "No writable log directory available. Make sure either the application directory or the Ryujinx directory is writable.");
LogDirectoryPath = null;
Logger.RemoveTarget("file");
return;
}
}
LogDirectoryPath = logDir;
Logger.AddTarget(new AsyncLogTargetWrapper(
new FileLogTarget("file", logFile),
1000,

View file

@ -1378,9 +1378,9 @@ namespace Ryujinx.Ui
{
string logPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
if (ReleaseInformation.IsValid)
if (LoggerModule.LogDirectoryPath != null)
{
logPath = System.IO.Path.Combine(AppDataManager.BaseDirPath, "Logs");
logPath = LoggerModule.LogDirectoryPath;
}
new DirectoryInfo(logPath).Create();