Skip to content

Commit 90e23e2

Browse files
authored
Merge pull request #1078 from github/timrogers/log-process-id
Add process ID to log file names to ensure uniqueness
2 parents 9305a91 + 3f24975 commit 90e23e2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
- Allow CLI to fail fast when an unauthorized token is provided by preventing retry logic on 401 errors
33
- Improve performance when reclaiming a single mannequin with `reclaim-mannequin`
44
- Improve logging for `reclaim-mannequin` command
5+
- Log filename now contains the process id to make sure it is unique

src/Octoshift/Services/OctoLogger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public class OctoLogger
3333
public OctoLogger()
3434
{
3535
var logStartTime = DateTime.Now;
36-
_logFilePath = $"{logStartTime:yyyyMMddHHmmss}.octoshift.log";
37-
_verboseFilePath = $"{logStartTime:yyyyMMddHHmmss}.octoshift.verbose.log";
36+
var processId = Environment.ProcessId;
37+
_logFilePath = $"{logStartTime:yyyyMMddHHmmss}-{processId}.octoshift.log";
38+
_verboseFilePath = $"{logStartTime:yyyyMMddHHmmss}-{processId}.octoshift.verbose.log";
3839

3940
if (Environment.GetEnvironmentVariable("GEI_DEBUG_MODE")?.ToUpperInvariant() == "TRUE")
4041
{

src/OctoshiftCLI.IntegrationTests/TestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ public void AssertNoErrorInLogs(DateTime after)
716716
var directoryInfo = new DirectoryInfo(GetOsDistPath());
717717

718718
var firstLogFileWithError = directoryInfo.GetFiles("*.octoshift.log")
719-
.Select(fi => (Timestamp: DateTime.ParseExact(fi.Name.Split('.').First(), "yyyyMMddHHmmss", null), FileInfo: fi))
719+
.Select(fi => (Timestamp: DateTime.ParseExact(fi.Name.Split('.').First().Split('-').First(), "yyyyMMddHHmmss", null), FileInfo: fi))
720720
.Where(x => x.Timestamp >= after)
721721
.OrderBy(x => x.Timestamp)
722722
.Select(x => x.FileInfo)

0 commit comments

Comments
 (0)