using Microsoft.Extensions.Logging;
using System;
// Same namespace as IConfiguration, to make these extensions appear
// without the user needing to including our namespace first.
namespace Microsoft.Extensions.Configuration
{
///
/// IConfiguration extensions
///
public static class IConfigurationExtensions
{
///
/// Creates LambdaLoggerOptions instance from "Lambda.Logging" section of the
/// specified configuration.
///
/// Configuration to get settings from.
///
[CLSCompliant(false)] // https://github.com/aspnet/Logging/issues/500
public static LambdaLoggerOptions GetLambdaLoggerOptions(this IConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}
return new LambdaLoggerOptions(configuration);
}
///
/// Creates LambdaLoggerOptions instance from the specified subsection of the
/// configuration section.
///
/// Configuration to get settings from.
/// Name of section from which to get configuration data.
///
[CLSCompliant(false)] // https://github.com/aspnet/Logging/issues/500
public static LambdaLoggerOptions GetLambdaLoggerOptions(this IConfiguration configuration, string loggingSectionName)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}
if (string.IsNullOrEmpty(loggingSectionName))
{
throw new ArgumentNullException(nameof(loggingSectionName));
}
return new LambdaLoggerOptions(configuration, loggingSectionName);
}
}
}