Skip to content

Commit e09990d

Browse files
committed
fix missing temp dir in logs
1 parent 6be7587 commit e09990d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

GitContentSearch/Helpers/SearchLogger.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,26 @@ public SearchLogger(TextWriter writer, Action<string>? progressCallback = null)
2626
_progressCallback = progressCallback;
2727
}
2828

29-
public void LogHeader(string operation, string workingDirectory, string targetFile)
29+
public void LogHeader(string operation, string workingDirectory, string targetFile, string? tempDirectory = null)
3030
{
3131
var divider = new string('=', 50);
3232
_writer.WriteLine(divider);
3333
_writer.WriteLine($"GitContentSearch {operation} started at {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
3434
_writer.WriteLine($"Working Directory (Git Repo): {workingDirectory}");
3535
_writer.WriteLine($"File to {operation.ToLower()}: {targetFile}");
36+
37+
// Use the provided temp directory or default to the standard path
38+
string tempDir = tempDirectory ?? Path.Combine(Path.GetTempPath(), "GitContentSearch");
39+
_writer.WriteLine($"Logs and temporary files will be created in: {tempDir}");
40+
3641
_writer.WriteLine(divider);
3742

3843
// Trigger LogAdded event for each line
3944
LogAdded?.Invoke(this, divider);
4045
LogAdded?.Invoke(this, $"GitContentSearch {operation} started at {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
4146
LogAdded?.Invoke(this, $"Working Directory (Git Repo): {workingDirectory}");
4247
LogAdded?.Invoke(this, $"File to {operation.ToLower()}: {targetFile}");
48+
LogAdded?.Invoke(this, $"Logs and temporary files will be created in: {tempDir}");
4349
LogAdded?.Invoke(this, divider);
4450
}
4551

GitContentSearch/Interfaces/ISearchLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace GitContentSearch.Interfaces
44
{
55
public interface ISearchLogger : IDisposable
66
{
7-
void LogHeader(string operation, string workingDirectory, string targetFile);
7+
void LogHeader(string operation, string workingDirectory, string targetFile, string? tempDirectory = null);
88
void LogProgress(string progressMessage);
99
void LogFooter();
1010
void LogError(string message, Exception? ex = null);

GitContentSearch/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void Main(string[] args)
4848

4949
using (var logger = CreateLogger(locateTempDir))
5050
{
51-
logger.LogHeader("locate", locateWorkingDir, fileName);
51+
logger.LogHeader("locate", locateWorkingDir, fileName, locateTempDir);
5252

5353
var processWrapper = new ProcessWrapper();
5454
var gitHelper = new GitHelper(processWrapper, locateWorkingDir, false, logger);
@@ -105,7 +105,7 @@ static void Main(string[] args)
105105

106106
using (var logger = CreateLogger(tempDir))
107107
{
108-
logger.LogHeader("search", workingDirectory, filePath);
108+
logger.LogHeader("search", workingDirectory, filePath, tempDir);
109109

110110
var processWrapper = new ProcessWrapper();
111111
var gitHelper = new GitHelper(processWrapper, workingDirectory, follow, logger);

0 commit comments

Comments
 (0)