Skip to content

Commit

Permalink
fix(Weaver): fixing WeaverDiagnosticsTimer for when directory is not …
Browse files Browse the repository at this point in the history
…found

also moving directly to Logs/WeaverLogs
  • Loading branch information
James-Frowen committed Jul 16, 2022
1 parent 49b8afd commit eb880d5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Assets/Mirage/Weaver/WeaverDiagnosticsTimer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using ConditionalAttribute = System.Diagnostics.ConditionalAttribute;
using Stopwatch = System.Diagnostics.Stopwatch;
Expand All @@ -20,14 +20,27 @@ internal class WeaverDiagnosticsTimer
writer = null;
}

static bool _checkDirectory = false;
static void CheckDirectory()
{
if (_checkDirectory)
return;
_checkDirectory = true;
if (!Directory.Exists("./Logs/WeaverLogs"))
{
Directory.CreateDirectory("./Logs/WeaverLogs");
}
}

[Conditional("WEAVER_DEBUG_TIMER")]
public void Start(string name)
{
this.name = name;

if (writeToFile)
{
var path = $"./Build/WeaverLogs/Timer_{name}.log";
CheckDirectory();
var path = $"./Logs/WeaverLogs/Timer_{name}.log";
try
{
writer = new StreamWriter(path)
Expand Down

0 comments on commit eb880d5

Please sign in to comment.