Add process ID to log filename #212

an attempt to mitigate a bug with rogold accidentally launching roblox twice when launching a game through one of its added features making bloxstrap error because both instances will have the same log filename

don't want to just terminate any launched instances that encounter the same filename since there could be a case of someone intentionally launching roblox repeatedly

this won't actually stop the double launching, there's not much way around that without being able to see the executing args of other bloxstrap instances, but it solves the error
This commit is contained in:
pizzaboxer 2023-05-24 11:02:57 +01:00
parent af26604980
commit c7a7feeebf
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -80,8 +80,9 @@ namespace Bloxstrap
bool isUsingTempDir = IsFirstRun || IsUninstall;
string logdir = isUsingTempDir ? Path.Combine(Directories.LocalAppData, "Temp") : Path.Combine(Directories.Base, "Logs");
string timestamp = DateTime.UtcNow.ToString("yyyyMMdd'T'HHmmss'Z'");
int processId = Process.GetCurrentProcess().Id;
Logger.Initialize(Path.Combine(logdir, $"{ProjectName}_{timestamp}.log"));
Logger.Initialize(Path.Combine(logdir, $"{ProjectName}_{timestamp}_{processId}.log"));
// clean up any logs older than a week
if (!isUsingTempDir)