Skip to content

Commit

Permalink
Fix potential error when writing runtime log (space-wizards#4575)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss authored Nov 19, 2023
1 parent 2fe4a8b commit c21b6c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Robust.Server/BaseServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,14 @@ public void Cleanup()
{
// Write down exception log
var logPath = _config.GetCVar(CVars.LogPath);
var relPath = PathHelpers.ExecutableRelativeFile(logPath);
Directory.CreateDirectory(relPath);
var pathToWrite = Path.Combine(relPath,
if (!Path.IsPathRooted(logPath))
{
logPath = PathHelpers.ExecutableRelativeFile(logPath);
}

var pathToWrite = Path.Combine(logPath,
"Runtime-" + DateTime.Now.ToString("yyyy-MM-dd-THH-mm-ss") + ".txt");
Directory.CreateDirectory(logPath);
File.WriteAllText(pathToWrite, _runtimeLog.Display(), EncodingHelpers.UTF8);
}

Expand Down

0 comments on commit c21b6c9

Please sign in to comment.