diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-08-06 16:54:38 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-08-06 16:54:38 -0500 |
| commit | c7578b0513c7c23db8ff1246d3f948b0b127c93e (patch) | |
| tree | 189bb5e406161483faf24405407250238de46baa /src/slskd/Program.cs | |
| parent | 5a5d4d06dc772bc4c78bfae9d66098f51c2e3c33 (diff) | |
| download | slskd-c7578b0513c7c23db8ff1246d3f948b0b127c93e.tar.gz | |
stub logic to log EF SQL
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 10 |
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 |
