Minor logging changes

This commit is contained in:
Tom 2024-10-20 19:28:16 +00:00
parent 0fa0ddcc45
commit 5d69c647cf
3 changed files with 15 additions and 9 deletions

View File

@ -69,7 +69,7 @@ namespace HermesSocketServer.Store
_added.Clear();
}
_logger.Debug($"ADD {count} " + sql);
_logger.Debug($"TtsChatVoice - Adding {count} rows to database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_modified.Any())
@ -80,7 +80,7 @@ namespace HermesSocketServer.Store
sql = _generator.GenerateUpdateSql("TtsChatVoice", _modified.Select(m => _store[m]), ["userId", "chatterId"], ["ttsVoiceId"]);
_modified.Clear();
}
_logger.Debug($"MOD {count} " + sql);
_logger.Debug($"TtsChatVoice - Modifying {count} rows in database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_deleted.Any())
@ -91,7 +91,7 @@ namespace HermesSocketServer.Store
sql = _generator.GenerateDeleteSql("TtsChatVoice", _deleted, ["userId", "chatterId"]);
_deleted.Clear();
}
_logger.Debug($"DEL {count} " + sql);
_logger.Debug($"TtsChatVoice - Deleting {count} rows from database: {sql}");
await _database.ExecuteScalar(sql);
}
return true;

View File

@ -58,34 +58,40 @@ namespace HermesSocketServer.Store
public override async Task<bool> Save()
{
int count = 0;
string sql = string.Empty;
if (_added.Any())
{
string sql = string.Empty;
lock (_lock)
{
count = _added.Count;
sql = _generator.GenerateInsertSql("User", _added.Select(a => _store[a]), ["id", "name", "email", "role", "ttsDefaultVoice"]);
_added.Clear();
}
_logger.Debug($"User - Adding {count} rows to database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_modified.Any())
{
string sql = string.Empty;
lock (_lock)
{
count = _modified.Count;
sql = _generator.GenerateUpdateSql("User", _modified.Select(m => _store[m]), ["id"], ["name", "email", "role", "ttsDefaultVoice"]);
_modified.Clear();
}
_logger.Debug($"User - Modifying {count} rows in database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_deleted.Any())
{
string sql = string.Empty;
lock (_lock)
{
count = _deleted.Count;
sql = _generator.GenerateDeleteSql("User", _deleted, ["id"]);
_deleted.Clear();
}
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
await _database.ExecuteScalar(sql);
}
return true;

View File

@ -72,7 +72,7 @@ namespace HermesSocketServer.Store
_added.Clear();
}
_logger.Debug($"ADD {count} " + sql);
_logger.Debug($"TtsVoice - Adding {count} rows to database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_modified.Any())
@ -83,7 +83,7 @@ namespace HermesSocketServer.Store
sql = _generator.GenerateUpdateSql("TtsVoice", _modified.Select(m => _store[m]), ["id"], ["name"]);
_modified.Clear();
}
_logger.Debug($"MOD {count} " + sql);
_logger.Debug($"TtsVoice - Modifying {count} rows in database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_deleted.Any())
@ -94,7 +94,7 @@ namespace HermesSocketServer.Store
sql = _generator.GenerateDeleteSql("TtsVoice", _deleted, ["id"]);
_deleted.Clear();
}
_logger.Debug($"DEL {count} " + sql);
_logger.Debug($"TtsVoice - Deleting {count} rows from database: {sql}");
await _database.ExecuteScalar(sql);
}
return true;