Skip to content

Commit fd42a32

Browse files
committed
add logging to file
1 parent e7ad445 commit fd42a32

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

AvaGui/Models/ObjectEditorModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ public class ObjectEditorModel
5151
public Collection<string> MiscFiles { get; } = [];
5252

5353
public const string ApplicationName = "OpenLoco Object Editor";
54+
public const string LoggingFileName = "objectEditor.log";
5455

5556
public static string SettingsPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ApplicationName);
5657

5758
public static string SettingsFile => Path.Combine(SettingsPath, Environment.GetEnvironmentVariable("ENV_SETTINGS_FILE") ?? "settings.json"); // "settings-dev.json" for dev, "settings.json" for prod
5859

60+
public static string LoggingFile => Path.Combine(SettingsPath, LoggingFileName);
61+
5962
public ObservableCollection<LogLine> LoggerObservableLogs = [];
6063

6164
public HttpClient? WebClient { get; }
@@ -65,6 +68,7 @@ public ObjectEditorModel()
6568
Logger = new Logger();
6669
LoggerObservableLogs = [];
6770
Logger.LogAdded += (sender, laea) => Dispatcher.UIThread.Post(() => LoggerObservableLogs.Insert(0, laea.Log));
71+
Logger.LogAdded += (sender, laea) => File.AppendAllLines(LoggingFile, [laea.Log.ToString()]);
6872

6973
LoadSettings();
7074

0 commit comments

Comments
 (0)