@@ -25,6 +25,7 @@ internal static class ModuleTrackerTemplate
25
25
public static bool SingleHit ;
26
26
public static bool FlushHitFile ;
27
27
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 ( ) ;
28
29
29
30
static ModuleTrackerTemplate ( )
30
31
{
@@ -173,7 +174,7 @@ private static void WriteHits(object sender)
173
174
Assembly currentAssembly = Assembly . GetExecutingAssembly ( ) ;
174
175
DirectoryInfo location = new DirectoryInfo ( Path . Combine ( Path . GetDirectoryName ( currentAssembly . Location ) , "TrackersHitsLog" ) ) ;
175
176
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") ;
177
178
using ( var fs = new FileStream ( HitsFilePath , FileMode . Open , FileAccess . ReadWrite , FileShare . None ) )
178
179
using ( var log = new FileStream ( logFile , FileMode . CreateNew , FileAccess . ReadWrite , FileShare . None ) )
179
180
using ( var logWriter = new StreamWriter ( log ) )
@@ -197,7 +198,7 @@ private static void WriteLog(string logText)
197
198
// We don't set path as global var to keep benign possible errors inside try/catch
198
199
// I'm not sure that location will be ok in every scenario
199
200
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 } ") ;
201
202
}
202
203
}
203
204
}
0 commit comments