Skip to content

Commit

Permalink
PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
normj committed Jun 26, 2019
1 parent a41e9fb commit 2c79776
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/AWS.Logger.AspNetCore/AWSLoggerBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public static ILoggingBuilder AddAWSProvider(this ILoggingBuilder builder, Func<
{
var serviceDescriptor = builder.Services.FirstOrDefault(x => x.ServiceType == typeof(IConfiguration));
if (serviceDescriptor == null)
{
return builder;
}

var configuration = serviceDescriptor.ImplementationInstance as IConfiguration;

Expand All @@ -77,10 +79,15 @@ public static ILoggingBuilder AddAWSProvider(this ILoggingBuilder builder, Func<
// and skip adding the provider. We don't want to prevent developers running their application
// locally because they don't have access or want to use AWS for their local development.
if (configuration == null)
{
return builder;
}

var configSection = configuration.GetAWSLoggingConfigSection();
if (configSection == null)
{
return builder;
}

return AddAWSProvider(builder, configSection, formatter);
}
Expand Down
4 changes: 2 additions & 2 deletions src/AWS.Logger.AspNetCore/AWSLoggerConfigSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public static class ConfigurationSectionExtensions
{
// Default configuration block on the appsettings.json
// Customer's information will be fetched from this block unless otherwise set.
const string DEFAULT_BLOCK = "Logging";
private const string DEFAULT_BLOCK = "Logging";

// This library was originally written before logging standarized, or it at least we didn't realize it was standarized, on the "Logging" section in the config.
// The library now uses "Logging" as the default section to look for config but to maintain backwards compatibility the package will fallback
// AWS.Logging if a log group is not configured in the "Logging" config block".
const string LEGACY_DEFAULT_BLOCK = "AWS.Logging";
private const string LEGACY_DEFAULT_BLOCK = "AWS.Logging";

/// <summary>
/// Loads the AWS Logger Configuration from the ConfigSection
Expand Down

0 comments on commit 2c79776

Please sign in to comment.