aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-08-06 16:54:38 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-08-06 16:54:38 -0500
commitc7578b0513c7c23db8ff1246d3f948b0b127c93e (patch)
tree189bb5e406161483faf24405407250238de46baa /src
parent5a5d4d06dc772bc4c78bfae9d66098f51c2e3c33 (diff)
downloadslskd-c7578b0513c7c23db8ff1246d3f948b0b127c93e.tar.gz
stub logic to log EF SQL
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Program.cs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 42e9ffab..5ed6bf80 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -15,6 +15,8 @@
// along with this program. If not, see https://www.gnu.org/licenses/.
// </copyright>
+using Microsoft.Extensions.Logging;
+
namespace slskd
{
using System;
@@ -790,13 +792,19 @@ namespace slskd
private static IServiceCollection AddDbContext<T>(this IServiceCollection services, string filename)
where T : DbContext
{
- Log.Debug($"Initializing database context {typeof(T).Name}");
+ Log.Debug("Initializing database context {Name}", typeof(T).Name);
try
{
services.AddDbContextFactory<T>(options =>
{
options.UseSqlite($"Data Source={Path.Combine(AppDirectory, "data", filename)}");
+
+ // tweak this to enable Entity Framework SQL logging
+ if (OptionsAtStartup.Debug && false)
+ {
+ options.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
+ }
});
using var ctx = services