Improved logging system.
This commit is contained in:
parent
d94b1cb813
commit
98d13ebbbb
24 changed files with 202 additions and 142 deletions
SharpChat.SQLite
|
@ -1,13 +1,15 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using SharpChat.Messages;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SQLite;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using ZLogger;
|
||||
|
||||
namespace SharpChat.SQLite;
|
||||
|
||||
public class SQLiteMessageStorage(SQLiteConnection conn) : MessageStorage {
|
||||
public class SQLiteMessageStorage(ILogger logger, SQLiteConnection conn) : MessageStorage {
|
||||
public async Task LogMessage(
|
||||
long id,
|
||||
string type,
|
||||
|
@ -37,7 +39,7 @@ public class SQLiteMessageStorage(SQLiteConnection conn) : MessageStorage {
|
|||
new SQLiteParameter("data", data == null ? "{}" : JsonSerializer.SerializeToUtf8Bytes(data))
|
||||
);
|
||||
} catch(SQLiteException ex) {
|
||||
Logger.Write(ex);
|
||||
logger.ZLogError($"Error in LogMessage(): {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +50,7 @@ public class SQLiteMessageStorage(SQLiteConnection conn) : MessageStorage {
|
|||
new SQLiteParameter("id", msg.Id)
|
||||
);
|
||||
} catch(SQLiteException ex) {
|
||||
Logger.Write(ex);
|
||||
logger.ZLogError($"Error in DeleteMessage(): {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +88,7 @@ public class SQLiteMessageStorage(SQLiteConnection conn) : MessageStorage {
|
|||
return evt;
|
||||
}
|
||||
} catch(SQLiteException ex) {
|
||||
Logger.Write(ex);
|
||||
logger.ZLogError($"Error in GetMessage(): {ex}");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -116,7 +118,7 @@ public class SQLiteMessageStorage(SQLiteConnection conn) : MessageStorage {
|
|||
msgs.Add(evt);
|
||||
}
|
||||
} catch(SQLiteException ex) {
|
||||
Logger.Write(ex);
|
||||
logger.ZLogError($"Error in GetMessages(): {ex}");
|
||||
}
|
||||
|
||||
msgs.Reverse();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue