Skip to content

Commit d427957

Browse files
Remove missing type inside CoreLib from the ModuleTrackerTemplate (#1286)
Remove missing type inside CoreLib from the ModuleTrackerTemplate
1 parent df968b8 commit d427957

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/coverlet.core/Instrumentation/ModuleTrackerTemplate.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ internal static class ModuleTrackerTemplate
2525
public static bool SingleHit;
2626
public static bool FlushHitFile;
2727
private static readonly bool _enableLog = int.TryParse(Environment.GetEnvironmentVariable("COVERLET_ENABLETRACKERLOG"), out int result) ? result == 1 : false;
28+
private static string _sessionId = Guid.NewGuid().ToString();
2829

2930
static ModuleTrackerTemplate()
3031
{
@@ -173,7 +174,7 @@ private static void WriteHits(object sender)
173174
Assembly currentAssembly = Assembly.GetExecutingAssembly();
174175
DirectoryInfo location = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(currentAssembly.Location), "TrackersHitsLog"));
175176
location.Create();
176-
string logFile = Path.Combine(location.FullName, $"{Path.GetFileName(currentAssembly.Location)}_{DateTime.UtcNow.Ticks}_{Process.GetCurrentProcess().Id}.txt");
177+
string logFile = Path.Combine(location.FullName, $"{Path.GetFileName(currentAssembly.Location)}_{DateTime.UtcNow.Ticks}_{_sessionId}.txt");
177178
using (var fs = new FileStream(HitsFilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
178179
using (var log = new FileStream(logFile, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None))
179180
using (var logWriter = new StreamWriter(log))
@@ -197,7 +198,7 @@ private static void WriteLog(string logText)
197198
// We don't set path as global var to keep benign possible errors inside try/catch
198199
// I'm not sure that location will be ok in every scenario
199200
string location = Assembly.GetExecutingAssembly().Location;
200-
File.AppendAllText(Path.Combine(Path.GetDirectoryName(location), Path.GetFileName(location) + "_tracker.txt"), $"[{DateTime.UtcNow} P:{Process.GetCurrentProcess().Id} T:{Thread.CurrentThread.ManagedThreadId}]{logText}{Environment.NewLine}");
201+
File.AppendAllText(Path.Combine(Path.GetDirectoryName(location), Path.GetFileName(location) + "_tracker.txt"), $"[{DateTime.UtcNow} S:{_sessionId} T:{Thread.CurrentThread.ManagedThreadId}]{logText}{Environment.NewLine}");
201202
}
202203
}
203204
}

0 commit comments

Comments
 (0)