Skip to content

Commit 7146b11

Browse files
committed
Add support for relative logfile paths
1 parent 6378553 commit 7146b11

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/GitVersionExe/Program.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,25 @@ static void ConfigureLogging(Arguments arguments)
129129
{
130130
try
131131
{
132-
Directory.CreateDirectory(Path.GetDirectoryName(arguments.LogFilePath));
133-
if (File.Exists(arguments.LogFilePath))
132+
var logFileFullPath = Path.GetFullPath(arguments.LogFilePath);
133+
var logFile = new FileInfo(logFileFullPath);
134+
135+
if (logFile.Directory != null && !logFile.Directory.Exists)
136+
// TODO: This should probably be done recursively. @asbjornu
137+
logFile.Directory.Create();
138+
139+
if (!logFile.Exists)
134140
{
135-
using (File.CreateText(arguments.LogFilePath)) { }
141+
using (logFile.CreateText())
142+
{
143+
}
136144
}
137145

138146
writeActions.Add(x => WriteLogEntry(arguments, x));
139147
}
140148
catch (Exception ex)
141149
{
142-
Console.WriteLine("Failed to configure logging: " + ex.Message);
150+
Console.WriteLine("Failed to configure logging for '{0}': {1}", arguments.LogFilePath, ex.Message);
143151
}
144152
}
145153

0 commit comments

Comments
 (0)