Skip to content

Commit 8cbaa33

Browse files
committed
Use NullLogger
1 parent 4ed3e91 commit 8cbaa33

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

ManagedCode.Communication.Extensions/ExceptionFilterBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.AspNetCore.Mvc.Filters;
55
using Microsoft.Extensions.Logging;
6+
using Microsoft.Extensions.Logging.Abstractions;
67
using static ManagedCode.Communication.Extensions.Helpers.HttpStatusCodeHelper;
78
using static ManagedCode.Communication.Extensions.Constants.ProblemConstants;
89

910
namespace ManagedCode.Communication.Extensions;
1011

11-
public abstract class ExceptionFilterBase(ILogger logger) : IExceptionFilter
12+
public abstract class ExceptionFilterBase : IExceptionFilter
1213
{
13-
protected readonly ILogger Logger = logger ?? throw new ArgumentNullException(nameof(logger));
14+
protected readonly ILogger Logger = NullLogger<ExceptionFilterBase>.Instance;
1415

1516
public virtual void OnException(ExceptionContext context)
1617
{

ManagedCode.Communication.Extensions/HubExceptionFilterBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
using System.Threading.Tasks;
33
using Microsoft.AspNetCore.SignalR;
44
using Microsoft.Extensions.Logging;
5+
using Microsoft.Extensions.Logging.Abstractions;
56
using static ManagedCode.Communication.Extensions.Helpers.HttpStatusCodeHelper;
67
using static ManagedCode.Communication.Extensions.Constants.ProblemConstants;
78

89
namespace ManagedCode.Communication.Extensions;
910

10-
public abstract class HubExceptionFilterBase(ILogger logger) : IHubFilter
11+
public abstract class HubExceptionFilterBase : IHubFilter
1112
{
12-
protected readonly ILogger Logger = logger ?? throw new ArgumentNullException(nameof(logger));
13+
protected readonly ILogger Logger = NullLogger.Instance;
1314

1415
public async ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext,
1516
Func<HubInvocationContext, ValueTask<object?>> next)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using ManagedCode.Communication.Extensions;
2-
using Microsoft.Extensions.Logging;
32

43
namespace ManagedCode.Communication.Tests.Common.TestApp;
54

6-
public class TestExceptionFilter(ILogger<TestExceptionFilter> logger) : ExceptionFilterBase(logger);
5+
public class TestExceptionFilter : ExceptionFilterBase;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using ManagedCode.Communication.Extensions;
2-
using Microsoft.Extensions.Logging;
32

43
namespace ManagedCode.Communication.Tests.Common.TestApp;
54

6-
public class TestHubExceptionFilter(ILogger<TestHubExceptionFilter> logger) : HubExceptionFilterBase(logger);
5+
public class TestHubExceptionFilter : HubExceptionFilterBase;

0 commit comments

Comments
 (0)