Add database log file

This commit is contained in:
2023-04-24 13:51:01 +02:00
parent 94055cb2c2
commit 0ecba36f51
2 changed files with 41 additions and 1 deletions

@ -8,6 +8,7 @@ namespace Elwig.Helpers {
private readonly string FileName;
public string DatabaseFile = App.DataPath + "database.sqlite3";
public string? DatabaseLog = null;
public Config(string filename) {
FileName = filename;
@ -28,11 +29,20 @@ namespace Elwig.Helpers {
} else {
DatabaseFile = App.DataPath + db;
}
if (ini == null || !ini.TryGetKey("database.log", out string log)) {
DatabaseLog = null;
} else if (log.Length > 1 && (log[1] == ':' || log[0] == '/' || log[0] == '\\')) {
DatabaseLog = log;
} else {
DatabaseLog = App.DataPath + log;
}
}
public void Write() {
using var file = new StreamWriter(FileName, false, Encoding.UTF8);
file.Write($"\n[database]\nfile = {DatabaseFile}\n");
file.Write($"\r\n[database]\r\nfile = {DatabaseFile}\r\n");
if (DatabaseLog != null) file.Write($"log = {DatabaseLog}\r\n");
}
}
}