Skip to content

Commit c528ba6

Browse files
committed
Automatic merge of T1.5.1-1806-g5522fc5fa and 13 pull requests
- Pull request #570 at 362e4e7: glTF 2.0 support with PBR lighting - Pull request #1062 at 1ec3dc6: Train Forces popup Window. - Pull request #1064 at 1be1fc4: Add Train Info tab to Help window (F1) - Pull request #1067 at b471b7c: Traction and dynamic brake retardation - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #1074 at e9a66c1: Gradient - commit 2024-16-12 - Pull request #1076 at 3bbd537: Allow depart early - Pull request #1085 at 37e2817: updates key commands for Train Operations window and also Daylight Offset - Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1087 at 1f64f02: Improve warning message for signal location mismatch. - Pull request #1088 at 4b3fa4c: Preserve previous log file. - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification
15 parents 203af04 + 5522fc5 + 362e4e7 + 1ec3dc6 + 1be1fc4 + b471b7c + 1f5ba4c + e9a66c1 + 3bbd537 + 37e2817 + e10390b + 1f64f02 + 4b3fa4c + 5845a1a + 689494b commit c528ba6

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

Source/RunActivity/Viewer3D/Processes/GameStateRunActivity.cs

+25-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class GameStateRunActivity : GameState
5252

5353
static Viewer Viewer { get { return Program.Viewer; } set { Program.Viewer = value; } }
5454
static ORTraceListener ORTraceListener { get { return Program.ORTraceListener; } set { Program.ORTraceListener = value; } }
55-
static string logFileName { get { return Program.logFileName; } set { Program.logFileName = value; } }
55+
static string logFilePath { get { return Program.logFileName; } set { Program.logFileName = value; } }
5656
static string EvaluationFilename { get { return Program.EvaluationFilename; } set { Program.EvaluationFilename = value; } }
5757

5858
/// <summary>
@@ -811,13 +811,30 @@ void InitLogging(UserSettings settings, string[] args, bool appendLog)
811811
{
812812
fileName = settings.LoggingFilename;
813813
}
814-
logFileName = GetFilePath(settings, fileName);
814+
logFilePath = GetFilePath(settings, fileName);
815815

816816
// Ensure we start with an empty file.
817817
if (!appendLog)
818-
File.Delete(logFileName);
818+
{
819+
if (File.Exists(logFilePath))
820+
{
821+
try
822+
{
823+
var logFileExtension = Path.GetExtension(logFilePath);
824+
var prevLogPath = Path.ChangeExtension(logFilePath, ".prev" + logFileExtension);
825+
if (File.Exists(prevLogPath)) { File.Delete(prevLogPath); }
826+
File.Move(logFilePath, prevLogPath);
827+
}
828+
catch (Exception e)
829+
{
830+
Console.WriteLine("Failed to move log file: " + e.Message);
831+
File.Delete(logFilePath);
832+
}
833+
}
834+
}
835+
819836
// Make Console.Out go to the log file AND the output stream.
820-
Console.SetOut(new FileTeeLogger(logFileName, Console.Out));
837+
Console.SetOut(new FileTeeLogger(logFilePath, Console.Out));
821838
// Make Console.Error go to the new Console.Out.
822839
Console.SetError(Console.Out);
823840
}
@@ -836,8 +853,8 @@ void InitLogging(UserSettings settings, string[] args, bool appendLog)
836853
LogSeparator();
837854
Console.WriteLine("Version = {0}", VersionInfo.Version.Length > 0 ? VersionInfo.Version : "<none>");
838855
Console.WriteLine("Build = {0}", VersionInfo.Build);
839-
if (logFileName.Length > 0)
840-
Console.WriteLine("Logfile = {0}", logFileName);
856+
if (logFilePath.Length > 0)
857+
Console.WriteLine("Logfile = {0}", logFilePath);
841858
Console.WriteLine("Executable = {0}", Path.GetFileName(ApplicationInfo.ProcessFile));
842859
foreach (var arg in args)
843860
Console.WriteLine("Argument = {0}", arg);
@@ -1045,8 +1062,8 @@ void UninitLoading()
10451062

10461063
static void CopyLog(string toFile)
10471064
{
1048-
if (logFileName.Length == 0) return;
1049-
File.Copy(logFileName, toFile, true);
1065+
if (logFilePath.Length == 0) return;
1066+
File.Copy(logFilePath, toFile, true);
10501067
}
10511068

10521069
void InitSimulator(UserSettings settings, string[] args, string mode)

0 commit comments

Comments
 (0)