Skip to content

Commit

Permalink
LoggerFactoryExtensions -> LoggingBuilderExtensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp authored and RehanSaeed committed Apr 29, 2021
1 parent 44a8adc commit 9dcb6a0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ Provides ASP.NET Core middleware, MVC filters, extension methods and helper code

- [ASP.NET Core Fluent Interface Extensions](https://rehansaeed.com/asp-net-core-fluent-interface-extensions/)

**ILoggerFactory Extensions**
**ILoggingBuilder Extensions**

```c#
loggerfactory
loggingBuilder
.AddIfElse(
hostingEnvironment.IsDevelopment(),
x => x.AddConsole(...).AddDebug(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ namespace Boxed.AspNetCore
using Microsoft.Extensions.Logging;

/// <summary>
/// <see cref="ILoggerFactory"/> extension methods.
/// <see cref="ILoggingBuilder"/> extension methods.
/// </summary>
public static class LoggerFactoryExtensions
public static class LoggingBuilderExtensions
{
/// <summary>
/// Executes the specified action if the specified <paramref name="condition"/> is <c>true</c> which can be
/// used to conditionally add to the logger factory.
/// used to conditionally add to the logging builder.
/// </summary>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="loggingBuilder">The logging builder.</param>
/// <param name="condition">If set to <c>true</c> the action is executed.</param>
/// <param name="action">The action used to add to the logger factory.</param>
/// <returns>The same logger factory.</returns>
public static ILoggerFactory AddIf(
this ILoggerFactory loggerFactory,
/// <param name="action">The action used to add to the logging builder.</param>
/// <returns>The same logging builder.</returns>
public static ILoggingBuilder AddIf(
this ILoggingBuilder loggingBuilder,
bool condition,
Func<ILoggerFactory, ILoggerFactory> action)
Func<ILoggingBuilder, ILoggingBuilder> action)
{
if (loggerFactory is null)
if (loggingBuilder is null)
{
throw new ArgumentNullException(nameof(loggerFactory));
throw new ArgumentNullException(nameof(loggingBuilder));
}

if (action is null)
Expand All @@ -33,32 +33,32 @@ public static ILoggerFactory AddIf(

if (condition)
{
loggerFactory = action(loggerFactory);
loggingBuilder = action(loggingBuilder);
}

return loggerFactory;
return loggingBuilder;
}

/// <summary>
/// Executes the specified <paramref name="ifAction"/> if the specified <paramref name="condition"/> is
/// <c>true</c>, otherwise executes the <paramref name="elseAction"/>. This can be used to conditionally add to
/// the logger factory.
/// the logging builder.
/// </summary>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="loggingBuilder">The logging builder.</param>
/// <param name="condition">If set to <c>true</c> the <paramref name="ifAction"/> is executed, otherwise the
/// <paramref name="elseAction"/> is executed.</param>
/// <param name="ifAction">The action used to add to the logger factory if the condition is <c>true</c>.</param>
/// <param name="elseAction">The action used to add to the logger factory if the condition is <c>false</c>.</param>
/// <returns>The same logger factory.</returns>
public static ILoggerFactory AddIfElse(
this ILoggerFactory loggerFactory,
/// <param name="ifAction">The action used to add to the logging builder if the condition is <c>true</c>.</param>
/// <param name="elseAction">The action used to add to the logging builder if the condition is <c>false</c>.</param>
/// <returns>The same logging builder.</returns>
public static ILoggingBuilder AddIfElse(
this ILoggingBuilder loggingBuilder,
bool condition,
Func<ILoggerFactory, ILoggerFactory> ifAction,
Func<ILoggerFactory, ILoggerFactory> elseAction)
Func<ILoggingBuilder, ILoggingBuilder> ifAction,
Func<ILoggingBuilder, ILoggingBuilder> elseAction)
{
if (loggerFactory is null)
if (loggingBuilder is null)
{
throw new ArgumentNullException(nameof(loggerFactory));
throw new ArgumentNullException(nameof(loggingBuilder));
}

if (ifAction is null)
Expand All @@ -73,14 +73,14 @@ public static ILoggerFactory AddIfElse(

if (condition)
{
loggerFactory = ifAction(loggerFactory);
loggingBuilder = ifAction(loggingBuilder);
}
else
{
loggerFactory = elseAction(loggerFactory);
loggingBuilder = elseAction(loggingBuilder);
}

return loggerFactory;
return loggingBuilder;
}
}
}

0 comments on commit 9dcb6a0

Please sign in to comment.