Skip to content

Commit

Permalink
Updated the Module to allow for overriding the creation of the logger…
Browse files Browse the repository at this point in the history
… in-case DI cannot.
  • Loading branch information
cdmdotnet committed Jan 14, 2024
1 parent da3bfef commit fc558d6
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ public virtual void RegisterLoggerComponents(IServiceCollection services)
if (isLoggerBound)
services.RemoveAll<ILogger>();

TTableStorageLogger logger = Resolve<TTableStorageLogger>(services);
TTableStorageLogger logger = InstantiateLogger(services);
services.AddSingleton<ILogger>(logger);
}

/// <summary>
/// Creates a new instance of the <typeparamref name="TTableStorageLogger"/>
/// </summary>
protected virtual TTableStorageLogger InstantiateLogger(IServiceCollection services)
{
TTableStorageLogger logger = Resolve<TTableStorageLogger>(services);

return logger;
}
}

/// <summary>
Expand All @@ -96,7 +106,6 @@ public virtual void RegisterLoggerComponents(IServiceCollection services)
public class AzureTableStorageLoggerModule
: AzureTableStorageLoggerModule<TableStorageLogger>
{

/// <summary>
/// Instantiate a new instance of the <see cref="AzureTableStorageLoggerModule"/> that uses the provided <paramref name="configurationManager"/>
/// to read the following configuration settings:
Expand Down

0 comments on commit fc558d6

Please sign in to comment.