Add database log file
This commit is contained in:
Elwig/Helpers
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user