Skip to content

Commit aeea621

Browse files
Ensure log directory is created
1 parent c005ef7 commit aeea621

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,17 @@ private void StartLogging()
298298

299299
private string GetLogDirPath()
300300
{
301-
if (!string.IsNullOrEmpty(LogPath))
301+
string logDir = !string.IsNullOrEmpty(LogPath)
302+
? Path.GetDirectoryName(LogPath)
303+
: Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
304+
305+
// Ensure logDir exists
306+
if (!Directory.Exists(logDir))
302307
{
303-
return Path.GetDirectoryName(LogPath);
308+
Directory.CreateDirectory(logDir);
304309
}
305310

306-
return Path.GetDirectoryName(
307-
Path.GetDirectoryName(
308-
Assembly.GetExecutingAssembly().Location));
311+
return logDir;
309312
}
310313

311314
private void RemovePSReadLineForStartup()

0 commit comments

Comments
 (0)