Separated out log's into a separate file for each run. It will keep up to 3
This commit is contained in:
parent
6db16b4110
commit
987755cc59
1 changed files with 15 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Logging
|
namespace Ryujinx.Common.Logging
|
||||||
|
@ -20,6 +21,20 @@ namespace Ryujinx.Common.Logging
|
||||||
|
|
||||||
public FileLogTarget(string path, string name, FileShare fileShare, FileMode fileMode)
|
public FileLogTarget(string path, string name, FileShare fileShare, FileMode fileMode)
|
||||||
{
|
{
|
||||||
|
// Ensure directory is present
|
||||||
|
DirectoryInfo logDir = new DirectoryInfo(Path.Combine(path, "Logs"));
|
||||||
|
logDir.Create();
|
||||||
|
|
||||||
|
// Clean up old logs, should only keep 3
|
||||||
|
FileInfo[] files = logDir.GetFiles("*.log").OrderBy((info => info.CreationTime)).ToArray();
|
||||||
|
for (int i = 0; i < files.Length - 2; i++)
|
||||||
|
{
|
||||||
|
files[i].Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get path for the current time
|
||||||
|
path = Path.Combine(logDir.FullName, $"Ryujinx_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.log");
|
||||||
|
|
||||||
_name = name;
|
_name = name;
|
||||||
_logWriter = new StreamWriter(File.Open(path, fileMode, FileAccess.Write, fileShare));
|
_logWriter = new StreamWriter(File.Open(path, fileMode, FileAccess.Write, fileShare));
|
||||||
_formatter = new DefaultLogFormatter();
|
_formatter = new DefaultLogFormatter();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue