Improved logging system.

This commit is contained in:
flash 2025-04-28 12:29:11 +00:00
commit 98d13ebbbb
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
24 changed files with 202 additions and 142 deletions
SharpChat.SQLite

View file

@ -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) {