Improved logging system.
This commit is contained in:
parent
d94b1cb813
commit
98d13ebbbb
24 changed files with 202 additions and 142 deletions
SharpChat.SQLite
|
@ -1,22 +1,25 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using SharpChat.Configuration;
|
||||
using SharpChat.Messages;
|
||||
using System.Data.SQLite;
|
||||
using ZLogger;
|
||||
using NativeSQLiteConnection = System.Data.SQLite.SQLiteConnection;
|
||||
|
||||
namespace SharpChat.SQLite;
|
||||
|
||||
public class SQLiteStorage(string connString) : Storage, IDisposable {
|
||||
public class SQLiteStorage(ILogger logger, string connString) : Storage, IDisposable {
|
||||
public const string MEMORY = "file::memory:?cache=shared";
|
||||
public const string DEFAULT = "sharpchat.db";
|
||||
|
||||
public SQLiteConnection Connection { get; } = new SQLiteConnection(new NativeSQLiteConnection(connString).OpenAndReturn());
|
||||
|
||||
public MessageStorage CreateMessageStorage() {
|
||||
return new SQLiteMessageStorage(Connection);
|
||||
return new SQLiteMessageStorage(logger, Connection);
|
||||
}
|
||||
|
||||
public async Task UpgradeStorage() {
|
||||
await new SQLiteMigrations(Connection).RunMigrations();
|
||||
logger.ZLogInformation($"Upgrading storage...");
|
||||
await new SQLiteMigrations(logger, Connection).RunMigrations();
|
||||
}
|
||||
|
||||
public static string BuildConnectionString(Config config) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue