Skip to content

Commit

Permalink
Initialize logger for YesSql to enable logging (#14659)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Nov 9, 2023
1 parent 0874a58 commit 92a9bf7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Data;
using System.IO;
using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OrchardCore.Data;
using OrchardCore.Data.Documents;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static OrchardCoreBuilder AddDataAccess(this OrchardCoreBuilder builder)
{
var tablePrefix = shellSettings["TablePrefix"].Trim() + databaseTableOptions.TableNameSeparator;

storeConfiguration = storeConfiguration.SetTablePrefix(tablePrefix);
storeConfiguration.SetTablePrefix(tablePrefix);
}

var store = StoreFactory.Create(storeConfiguration);
Expand Down Expand Up @@ -170,9 +171,10 @@ public static OrchardCoreBuilder AddDataAccess(this OrchardCoreBuilder builder)
return builder;
}

private static IConfiguration GetStoreConfiguration(IServiceProvider sp, YesSqlOptions yesSqlOptions, DatabaseTableOptions databaseTableOptions)
private static YesSql.Configuration GetStoreConfiguration(IServiceProvider sp, YesSqlOptions yesSqlOptions, DatabaseTableOptions databaseTableOptions)
{
var tableNameFactory = sp.GetRequiredService<ITableNameConventionFactory>();
var loggerFactory = sp.GetRequiredService<ILoggerFactory>();

var storeConfiguration = new YesSql.Configuration
{
Expand All @@ -181,6 +183,7 @@ private static IConfiguration GetStoreConfiguration(IServiceProvider sp, YesSqlO
ContentSerializer = new PoolingJsonContentSerializer(sp.GetService<ArrayPool<char>>()),
TableNameConvention = tableNameFactory.Create(databaseTableOptions),
IdentityColumnSize = Enum.Parse<IdentityColumnSize>(databaseTableOptions.IdentityColumnSize),
Logger = loggerFactory.CreateLogger("YesSql"),
};

if (yesSqlOptions.IdGenerator != null)
Expand Down

0 comments on commit 92a9bf7

Please sign in to comment.